Skip to content

Commit 8257643

Browse files
author
arch
committed
fix logging
1 parent 7ea43cd commit 8257643

File tree

4 files changed

+15
-109
lines changed

4 files changed

+15
-109
lines changed

funscript_editor/api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
from funscript_editor.utils.logging import setup_logging
77
from funscript_editor.ui.funscript_editor_window import FunscriptEditorWindow
88
from funscript_editor.ui.minimal import MinimalFunscriptGenerator
9+
from funscript_editor.utils.config import VERSION
910

1011
from PyQt5 import QtCore, QtGui, QtWidgets
1112

1213

1314
def show_editor() -> None:
1415
""" Show the Funscript Editor Main Window """
1516
setup_logging()
17+
logging.info("Python Funscript Editor %s", VERSION)
1618
app = QtWidgets.QApplication(sys.argv)
1719
widget = FunscriptEditorWindow()
1820
widget.show()
@@ -28,6 +30,7 @@ def generate_funscript(video_file: str, start_time: int, output_file: str) -> No
2830
output_file (str): path for the output file
2931
"""
3032
setup_logging()
33+
logging.info("Python Funscript Generator %s", VERSION)
3134
app = QtWidgets.QApplication(sys.argv)
3235
generator = MinimalFunscriptGenerator(video_file, start_time, output_file)
3336
generator.run()

funscript_editor/config/logging_linux.yaml

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4,73 +4,24 @@ disable_existing_loggers: false
44
formatters:
55
standard:
66
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
7-
error:
8-
format: "%(levelname)s <PID %(process)d:%(processName)s> %(name)s.%(funcName)s(): %(message)s"
97

108
handlers:
119
console:
1210
class: logging.StreamHandler
13-
level: DEBUG
11+
level: INFO
1412
formatter: standard
1513
stream: ext://sys.stdout
1614

17-
info_file_handler:
15+
file_handler:
1816
class: logging.handlers.RotatingFileHandler
1917
level: INFO
2018
formatter: standard
21-
filename: /tmp/funscript_editor/info.log
22-
maxBytes: 10485760 # 10MB
23-
backupCount: 10
24-
encoding: utf8
25-
26-
error_file_handler:
27-
class: logging.handlers.RotatingFileHandler
28-
level: ERROR
29-
formatter: error
30-
filename: /tmp/funscript_editor/errors.log
31-
maxBytes: 10485760 # 10MB
32-
backupCount: 10
33-
encoding: utf8
34-
35-
debug_file_handler:
36-
class: logging.handlers.RotatingFileHandler
37-
level: DEBUG
38-
formatter: standard
39-
filename: /tmp/funscript_editor/debug.log
40-
maxBytes: 10485760 # 10MB
41-
backupCount: 10
42-
encoding: utf8
43-
44-
critical_file_handler:
45-
class: logging.handlers.RotatingFileHandler
46-
level: CRITICAL
47-
formatter: standard
48-
filename: /tmp/funscript_editor/critical.log
49-
maxBytes: 10485760 # 10MB
50-
backupCount: 10
51-
encoding: utf8
52-
53-
warn_file_handler:
54-
class: logging.handlers.RotatingFileHandler
55-
level: WARN
56-
formatter: standard
57-
filename: /tmp/funscript_editor/warn.log
19+
filename: /tmp/funscript_editor.log
5820
maxBytes: 10485760 # 10MB
5921
backupCount: 10
6022
encoding: utf8
6123

6224
root:
6325
level: NOTSET
64-
handlers: [console]
26+
handlers: [console, file_handler]
6527
propogate: yes
66-
67-
loggers:
68-
<module>:
69-
level: DEBUG
70-
handlers: [console, info_file_handler, error_file_handler, critical_file_handler, debug_file_handler, warn_file_handler]
71-
propogate: no
72-
73-
<module.x>:
74-
level: DEBUG
75-
handlers: [info_file_handler, error_file_handler, critical_file_handler, debug_file_handler, warn_file_handler]
76-
propogate: yes

funscript_editor/config/logging_windows.yaml

Lines changed: 5 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,73 +4,24 @@ disable_existing_loggers: false
44
formatters:
55
standard:
66
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
7-
error:
8-
format: "%(levelname)s <PID %(process)d:%(processName)s> %(name)s.%(funcName)s(): %(message)s"
97

108
handlers:
119
console:
1210
class: logging.StreamHandler
13-
level: DEBUG
11+
level: INFO
1412
formatter: standard
1513
stream: ext://sys.stdout
1614

17-
info_file_handler:
15+
file_handler:
1816
class: logging.handlers.RotatingFileHandler
1917
level: INFO
2018
formatter: standard
21-
filename: logs\\info.log
22-
maxBytes: 10485760 # 10MB
23-
backupCount: 20
24-
encoding: utf8
25-
26-
error_file_handler:
27-
class: logging.handlers.RotatingFileHandler
28-
level: ERROR
29-
formatter: error
30-
filename: logs\\errors.log
31-
maxBytes: 10485760 # 10MB
32-
backupCount: 20
33-
encoding: utf8
34-
35-
debug_file_handler:
36-
class: logging.handlers.RotatingFileHandler
37-
level: DEBUG
38-
formatter: standard
39-
filename: logs\\debug.log
40-
maxBytes: 10485760 # 10MB
41-
backupCount: 20
42-
encoding: utf8
43-
44-
critical_file_handler:
45-
class: logging.handlers.RotatingFileHandler
46-
level: CRITICAL
47-
formatter: standard
48-
filename: logs\\critical.log
19+
filename: logs/funscript_editor.log
4920
maxBytes: 10485760 # 10MB
50-
backupCount: 20
51-
encoding: utf8
52-
53-
warn_file_handler:
54-
class: logging.handlers.RotatingFileHandler
55-
level: WARN
56-
formatter: standard
57-
filename: logs\\warn.log
58-
maxBytes: 10485760 # 10MB
59-
backupCount: 20
21+
backupCount: 10
6022
encoding: utf8
6123

6224
root:
6325
level: NOTSET
64-
handlers: [console]
26+
handlers: [console, file_handler]
6527
propogate: yes
66-
67-
loggers:
68-
<module>:
69-
level: DEBUG
70-
handlers: [console, info_file_handler, error_file_handler, critical_file_handler, debug_file_handler, warn_file_handler]
71-
propogate: no
72-
73-
<module.x>:
74-
level: DEBUG
75-
handlers: [info_file_handler, error_file_handler, critical_file_handler, debug_file_handler, warn_file_handler]
76-
propogate: yes

funscript_editor/utils/logging.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def setup_logging(
2727
""" Logging Setup
2828
2929
Args:
30-
default_level (int): logging level from logging python module e.g. `logging.INFO` (default is `logging.INFO`).
30+
default_level (int): logging level e.g. `logging.INFO` (default is `logging.DEBUG`).
3131
env_key (str, optional): env variable name to load a configuration file via environment variable (default is `LOG_CFG`).
3232
"""
3333
config_path = WINDOWS_LOG_CONFIG_FILE if platform.system() == 'Windows' else LINUX_LOG_CONFIG_FILE
@@ -39,7 +39,8 @@ def setup_logging(
3939
config = yaml.safe_load(f.read())
4040
create_log_directories(config)
4141
logging.config.dictConfig(config)
42-
coloredlogs.install()
42+
coloredlogs.install(level=default_level)
43+
logging.debug('Loging setup completed')
4344
except Exception as e:
4445
print(e)
4546
print('Error in Logging Configuration. Using default configs')

0 commit comments

Comments
 (0)