From 0bc54dc2f0bd03e863b0d49899493eb5c1143e9a Mon Sep 17 00:00:00 2001 From: Jessie Ross Date: Fri, 21 Jun 2024 12:13:00 +0700 Subject: [PATCH] Move debug logging logic to config.py --- superset/config.py | 6 +++--- superset/utils/logging_configurator.py | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/superset/config.py b/superset/config.py index d3a4694a03a18..0177aaafce41c 100644 --- a/superset/config.py +++ b/superset/config.py @@ -893,7 +893,7 @@ class D3TimeFormat(TypedDict, total=False): # Console Log Settings LOG_FORMAT = "%(asctime)s:%(levelname)s:%(name)s:%(message)s" -LOG_LEVEL = logging.INFO +LOG_LEVEL = logging.DEBUG if DEBUG else logging.INFO # --------------------------------------------------- # Enable Time Rotate Log Handler @@ -901,7 +901,7 @@ class D3TimeFormat(TypedDict, total=False): # LOG_LEVEL = DEBUG, INFO, WARNING, ERROR, CRITICAL ENABLE_TIME_ROTATE = False -TIME_ROTATE_LOG_LEVEL = logging.INFO +TIME_ROTATE_LOG_LEVEL = logging.DEBUG if DEBUG else logging.INFO FILENAME = os.path.join(DATA_DIR, "superset.log") ROLLOVER = "midnight" INTERVAL = 1 @@ -1180,7 +1180,7 @@ def CSV_TO_HIVE_UPLOAD_DIRECTORY_FUNC( # pylint: disable=invalid-name # Whether to bump the logging level to ERROR on the flask_appbuilder package # Set to False if/when debugging FAB related issues like # permission management -SILENCE_FAB = True +SILENCE_FAB = not DEBUG FAB_ADD_SECURITY_VIEWS = True FAB_ADD_SECURITY_PERMISSION_VIEW = False diff --git a/superset/utils/logging_configurator.py b/superset/utils/logging_configurator.py index 259b98c64c8d9..2d53d535cda6e 100644 --- a/superset/utils/logging_configurator.py +++ b/superset/utils/logging_configurator.py @@ -43,9 +43,7 @@ def configure_logging( # basicConfig() will set up a default StreamHandler on stderr logging.basicConfig(format=app_config["LOG_FORMAT"]) - logging.getLogger().setLevel( - logging.DEBUG if debug_mode else app_config["LOG_LEVEL"] - ) + logging.getLogger().setLevel(app_config["LOG_LEVEL"]) if app_config["ENABLE_TIME_ROTATE"]: logging.getLogger().setLevel(app_config["TIME_ROTATE_LOG_LEVEL"])