Skip to content

Commit 7686a0a

Browse files
author
arch
committed
improve logging
1 parent c149be1 commit 7686a0a

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

funscript_editor/api.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import sys
2-
import logging
32
import os
43
import cv2
54

6-
from funscript_editor.utils.logging import setup_logging
5+
import funscript_editor.utils.logging as logging
76
from funscript_editor.ui.funscript_editor_window import FunscriptEditorWindow
87
from funscript_editor.ui.funscript_generator_window import FunscriptGeneratorWindow
98
from funscript_editor.utils.config import VERSION
@@ -13,9 +12,10 @@
1312

1413
def show_editor() -> None:
1514
""" Show the Funscript Editor Main Window """
16-
setup_logging(silent=False)
17-
logging.info("Python Funscript Editor %s", VERSION)
18-
logging.info("Startup Path: %s", str(os.getcwd()))
15+
logging.setup_logging(silent=False)
16+
logger = logging.getLogger(__name__)
17+
logger.info("Python Funscript Editor %s", VERSION)
18+
logger.info("Startup Path: %s", str(os.getcwd()))
1919
app = QtWidgets.QApplication(sys.argv)
2020
widget = FunscriptEditorWindow()
2121
widget.show()
@@ -37,10 +37,11 @@ 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(silent=True)
41-
logging.info("Python Funscript Generator %s", VERSION)
42-
logging.info("Startup Path: %s", str(os.getcwd()))
43-
logging.info("Args: video_file=%s, start_time=%s, end_time=%s, output_file=%s", \
40+
logging.setup_logging(silent=True)
41+
logger = logging.getLogger(__name__)
42+
logger.info("Python Funscript Generator %s", VERSION)
43+
logger.info("Startup Path: %s", str(os.getcwd()))
44+
logger.info("Args: video_file=%s, start_time=%s, end_time=%s, output_file=%s", \
4445
str(video_file), str(start_time), str(end_time), str(output_file))
4546
app = QtWidgets.QApplication(sys.argv)
4647
_ = FunscriptGeneratorWindow(video_file, start_time, end_time, output_file, include_multiaxis_options)

funscript_editor/ui/funscript_generator_window.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from funscript_editor.ui.settings_dialog import SettingsDialog
1313
import funscript_editor.definitions as definitions
1414
from funscript_editor.ui.theme import setup_theme
15-
from funscript_editor.utils.config import SETTINGS, PROJECTION
15+
from funscript_editor.utils.config import SETTINGS, PROJECTION, HYPERPARAMETER
1616

1717
from PyQt5 import QtCore, QtGui, QtWidgets
1818

@@ -84,6 +84,9 @@ def __init__(self,
8484

8585
self.__logger.info("Set End Time to Frame Number %d", self.end_frame)
8686

87+
self.__logger.info("Hyperparameter:" + str(HYPERPARAMETER))
88+
self.__logger.info("Config:" + str(SETTINGS))
89+
8790
self.settings = {}
8891
if USE_OPTICALFLOW:
8992
self.run_opticalflow()
@@ -132,6 +135,7 @@ def __funscript_generated(self, funscripts, msg, success) -> None:
132135

133136
with open(self.output_file, 'w') as f:
134137
json.dump(funscript_json_output, f)
138+
f.flush()
135139
else:
136140
# dump to CSV
137141
if len(funscripts) > 1:
@@ -141,6 +145,8 @@ def __funscript_generated(self, funscripts, msg, success) -> None:
141145
for item in funscripts[first_metric].get_actions():
142146
f.write('{at};{pos}\n'.format(at=item['at'], pos=item['pos']))
143147

148+
f.flush()
149+
144150
self.__logger.info("Save result to %s", self.output_file)
145151
if not success: self.__show_message(msg, error=True)
146152
if platform.system() == 'Windows':

0 commit comments

Comments
 (0)