Skip to content

Commit 6bb1dbe

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

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

funscript_editor/__main__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def main():
1010
parser = argparse.ArgumentParser()
1111
parser.add_argument("--generator", action = 'store_true', help = "Run only the generator")
1212
parser.add_argument("--multiaxis", action = 'store_true', help = "Show options for multiaxis output")
13+
parser.add_argument("--logs", action = 'store_true', help = "Enable logging")
1314
parser.add_argument("-i", "--input", type = str, help = "Video File")
1415
parser.add_argument("-o", "--output", type = str, default = "/tmp/funscript_actions.json", help = "Output Path")
1516
parser.add_argument("-s", "--start", type = float, default = 0.0, help = "Start Time in Milliseconds")
@@ -20,4 +21,4 @@ def main():
2021
os.environ['PATH'] = os.getcwd() + os.sep + os.environ['PATH']
2122

2223
if not args.generator: show_editor()
23-
else: generate_funscript(args.input, args.start, args.end, args.output, args.multiaxis)
24+
else: generate_funscript(args.input, args.start, args.end, args.output, args.multiaxis, args.logs)

funscript_editor/api.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def generate_funscript(
2727
start_time: float,
2828
end_time :float,
2929
output_file: str,
30-
include_multiaxis_options: bool = False) -> None:
30+
include_multiaxis_options: bool = False,
31+
enable_logging: bool = False) -> None:
3132
""" Generate a funscript with minimal UI
3233
3334
Args:
@@ -37,7 +38,10 @@ def generate_funscript(
3738
output_file (str): path for the output file
3839
include_multiaxis_options (bool): include options for multiaxis output
3940
"""
40-
logging.setup_logging(silent=True)
41+
if enable_logging:
42+
logging.setup_logging(silent=True)
43+
else:
44+
logging.disable_logging()
4145
logger = logging.getLogger(__name__)
4246
logger.info("Python Funscript Generator %s", VERSION)
4347
logger.info("Startup Path: %s", str(os.getcwd()))

funscript_editor/utils/logging.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def get_logfiles_paths() -> list:
138138

139139

140140
def setup_logging(
141-
silent=False,
141+
silent: bool = False,
142142
default_level :int = logging.INFO,
143143
env_key :str = 'LOG_CFG') -> None:
144144
""" Logging Setup
@@ -173,3 +173,7 @@ def setup_logging(
173173
if not silent:
174174
coloredlogs.install(level=default_level)
175175
print('Failed to load configuration file. Using default configs')
176+
177+
178+
def disable_logging():
179+
logging.disable(logging.CRITICAL)

0 commit comments

Comments
 (0)