Эх сурвалжийг харах

add --loglevel commandline argument for logging
remove the progressbar for extension installation in favor of logging output

AUTOMATIC1111 2 жил өмнө
parent
commit
edfae9e78a

+ 1 - 0
modules/cmd_args.py

@@ -16,6 +16,7 @@ parser.add_argument("--test-server", action='store_true', help="launch.py argume
 parser.add_argument("--log-startup", action='store_true', help="launch.py argument: print a detailed log of what's happening at startup")
 parser.add_argument("--skip-prepare-environment", action='store_true', help="launch.py argument: skip all environment preparation")
 parser.add_argument("--skip-install", action='store_true', help="launch.py argument: skip installation of packages")
+parser.add_argument("--loglevel", type=str, help="log level; one of: CRITICAL, ERROR, WARNING, INFO, DEBUG", default=None)
 parser.add_argument("--do-not-download-clip", action='store_true', help="do not download CLIP model even if it's not included in the checkpoint")
 parser.add_argument("--data-dir", type=str, default=os.path.dirname(os.path.dirname(os.path.realpath(__file__))), help="base path where all user data is stored")
 parser.add_argument("--config", type=str, default=sd_default_config, help="path to config which constructs model",)

+ 0 - 12
modules/initialize_util.py

@@ -1,5 +1,4 @@
 import json
-import logging
 import os
 import signal
 import sys
@@ -7,17 +6,6 @@ import re
 
 from modules.timer import startup_timer
 
-def setup_logging():
-    # We can't use cmd_opts for this because it will not have been initialized at this point.
-    log_level = os.environ.get("SD_WEBUI_LOG_LEVEL")
-    if log_level:
-        log_level = getattr(logging, log_level.upper(), None) or logging.INFO
-        logging.basicConfig(
-            level=log_level,
-            format='%(asctime)s %(levelname)s [%(name)s] %(message)s',
-            datefmt='%Y-%m-%d %H:%M:%S',
-        )
-
 
 def gradio_server_name():
     from modules.shared_cmd_options import cmd_opts

+ 5 - 4
modules/launch_utils.py

@@ -1,4 +1,5 @@
 # this scripts installs necessary requirements and launches main program in webui.py
+import logging
 import re
 import subprocess
 import os
@@ -11,8 +12,10 @@ from functools import lru_cache
 from modules import cmd_args, errors
 from modules.paths_internal import script_path, extensions_dir
 from modules.timer import startup_timer
+from modules import logging_config
 
 args, _ = cmd_args.parser.parse_known_args()
+logging_config.setup_logging(args.loglevel)
 
 python = sys.executable
 git = os.environ.get('GIT', "git")
@@ -248,10 +251,8 @@ def run_extensions_installers(settings_file):
         return
 
     with startup_timer.subcategory("run extensions installers"):
-        import tqdm
-        progress_bar = tqdm.tqdm(list_extensions(settings_file))
-        for dirname_extension in progress_bar:
-            progress_bar.set_description(f"Installing {dirname_extension}")
+        for dirname_extension in list_extensions(settings_file):
+            logging.debug(f"Installing {dirname_extension}")
 
             path = os.path.join(extensions_dir, dirname_extension)
 

+ 16 - 0
modules/logging_config.py

@@ -0,0 +1,16 @@
+import os
+import logging
+
+
+def setup_logging(loglevel):
+    if loglevel is None:
+        loglevel = os.environ.get("SD_WEBUI_LOG_LEVEL")
+
+    if loglevel:
+        log_level = getattr(logging, loglevel.upper(), None) or logging.INFO
+        logging.basicConfig(
+            level=log_level,
+            format='%(asctime)s %(levelname)s [%(name)s] %(message)s',
+            datefmt='%Y-%m-%d %H:%M:%S',
+        )
+

+ 0 - 2
webui.py

@@ -10,8 +10,6 @@ from modules import initialize
 startup_timer = timer.startup_timer
 startup_timer.record("launcher")
 
-initialize_util.setup_logging()
-
 initialize.imports()
 
 initialize.check_versions()