Skip to content

Commit d6788d6

Browse files
author
arch
committed
improve logging
1 parent 1651272 commit d6788d6

File tree

5 files changed

+17
-20
lines changed

5 files changed

+17
-20
lines changed

contrib/Installer/assets/main.lua.next

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function start_funscript_generator()
4444
end
4545

4646
scriptIdx = ofs.ActiveIdx()
47-
local tmpFile = ofs.ExtensionDir() .. "/" .. tmpFileName
47+
local tmpFile = ofs.ExtensionDir() .. "/" .. tmpFileName
4848
local video = player.CurrentVideo()
4949
local script = ofs.Script(scriptIdx)
5050
local currentTimeMs = player.CurrentTime() * 1000
@@ -77,7 +77,7 @@ function start_funscript_generator()
7777
end
7878

7979
table.insert(args, "--generator")
80-
80+
8181
if multiaxis then;
8282
table.insert(args, "--multiaxis")
8383
end
@@ -140,7 +140,7 @@ function import_funscript_generator_json_result()
140140
print('Funscript Generator json output file not found')
141141
return
142142
end
143-
143+
144144
local content = f:read("*a")
145145
f:close()
146146
json_body = json.decode(content)

funscript_editor/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
def show_editor() -> None:
1515
""" Show the Funscript Editor Main Window """
16-
setup_logging()
16+
setup_logging(silent=False)
1717
logging.info("Python Funscript Editor %s", VERSION)
1818
logging.info("Startup Path: %s", str(os.getcwd()))
1919
app = QtWidgets.QApplication(sys.argv)
@@ -37,7 +37,7 @@ def generate_funscript(
3737
output_file (str): path for the output file
3838
include_multiaxis_options (bool): include options for multiaxis output
3939
"""
40-
setup_logging()
40+
setup_logging(silent=True)
4141
logging.info("Python Funscript Generator %s", VERSION)
4242
logging.info("Startup Path: %s", str(os.getcwd()))
4343
logging.info("Args: video_file=%s, start_time=%s, end_time=%s, output_file=%s", \

funscript_editor/config/logging_windows.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ handlers:
2323

2424
root:
2525
level: NOTSET
26-
handlers: [file_handler]
26+
handlers: [file_handler, console]
2727
propogate: yes

funscript_editor/config/settings.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,5 @@ dark_theme: False
3939
# enable the tracking plausiblity check
4040
tracking_plausibility_check: False
4141

42-
# enable logging on windows. logging cause some problems on windows only enable for debugging.
43-
logging: False
44-
4542
# timeout for an ffmpeg stream
4643
ffmpeg_timeout_in_seconds: 15

funscript_editor/utils/logging.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import logging.config
99

1010
from funscript_editor.definitions import WINDOWS_LOG_CONFIG_FILE, LINUX_LOG_CONFIG_FILE
11-
from funscript_editor.utils.config import SETTINGS
1211

1312

1413
def create_log_directories(config: dict) -> None:
@@ -116,13 +115,7 @@ def getLogger(name) -> LoggerInterface:
116115
Args:
117116
name (str): name of the logger instance
118117
"""
119-
if platform.system() == 'Windows':
120-
if SETTINGS['logging']:
121-
return PythonLogger(name)
122-
else:
123-
return DevZeroLogger(name)
124-
else:
125-
return PythonLogger(name)
118+
return PythonLogger(name)
126119

127120

128121
def get_logfiles_paths() -> list:
@@ -145,6 +138,7 @@ def get_logfiles_paths() -> list:
145138

146139

147140
def setup_logging(
141+
silent=False,
148142
default_level :int = logging.INFO,
149143
env_key :str = 'LOG_CFG') -> None:
150144
""" Logging Setup
@@ -160,16 +154,22 @@ def setup_logging(
160154
with open(config_path, 'rt') as f:
161155
try:
162156
config = yaml.safe_load(f.read())
157+
if silent:
158+
if "console" in config["root"]["handlers"]:
159+
config["root"]["handlers"] = [x for x in config["root"]["handlers"] if x != "console"]
163160
create_log_directories(config)
164161
logging.config.dictConfig(config)
165-
coloredlogs.install(level=default_level)
162+
if not silent:
163+
coloredlogs.install(level=default_level)
166164
logging.debug('Loging setup completed')
167165
except Exception as e:
168166
print(e)
169167
print('Error in Logging Configuration. Using default configs')
170168
logging.basicConfig(level=default_level)
171-
coloredlogs.install(level=default_level)
169+
if not silent:
170+
coloredlogs.install(level=default_level)
172171
else:
173172
logging.basicConfig(level=default_level)
174-
coloredlogs.install(level=default_level)
173+
if not silent:
174+
coloredlogs.install(level=default_level)
175175
print('Failed to load configuration file. Using default configs')

0 commit comments

Comments
 (0)