From 6f021d8aa0261f7e61db6c6199d942c53a42a965 Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Fri, 4 Oct 2024 10:05:34 -0400 Subject: [PATCH] Let --verbose have an argument for the log level. --- app/logger.py | 4 ++-- comfy/cli_args.py | 2 +- main.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/logger.py b/app/logger.py index 17662c9e..4ca0ea88 100644 --- a/app/logger.py +++ b/app/logger.py @@ -10,14 +10,14 @@ def get_logs(): return "\n".join([formatter.format(x) for x in logs]) -def setup_logger(verbose: bool = False, capacity: int = 300): +def setup_logger(log_level: str = 'INFO', capacity: int = 300): global logs if logs: return # Setup default global logger logger = logging.getLogger() - logger.setLevel(logging.DEBUG if verbose else logging.INFO) + logger.setLevel(log_level) stream_handler = logging.StreamHandler() stream_handler.setFormatter(logging.Formatter("%(message)s")) diff --git a/comfy/cli_args.py b/comfy/cli_args.py index ed0bbec6..20b9f474 100644 --- a/comfy/cli_args.py +++ b/comfy/cli_args.py @@ -136,7 +136,7 @@ parser.add_argument("--disable-all-custom-nodes", action="store_true", help="Dis parser.add_argument("--multi-user", action="store_true", help="Enables per-user storage.") -parser.add_argument("--verbose", action="store_true", help="Enables more debug prints.") +parser.add_argument("--verbose", default='INFO', const='DEBUG', nargs="?", choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], help='Set the logging level') # The default built-in provider hosted under web/ DEFAULT_VERSION_STRING = "comfyanonymous/ComfyUI@latest" diff --git a/main.py b/main.py index 3f5e2137..c2321086 100644 --- a/main.py +++ b/main.py @@ -9,7 +9,7 @@ from comfy.cli_args import args from app.logger import setup_logger -setup_logger(verbose=args.verbose) +setup_logger(log_level=args.verbose) def execute_prestartup_script():