From cab950866cc1dc5b150ecd4f286915f4290ee6d1 Mon Sep 17 00:00:00 2001 From: Yee Hing Tong Date: Wed, 18 Jan 2023 17:05:31 -0800 Subject: [PATCH 1/2] flip the settings for channel and logger Signed-off-by: Yee Hing Tong --- flytekit/loggers.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/flytekit/loggers.py b/flytekit/loggers.py index 0c8c2e035a..465a47e1fb 100644 --- a/flytekit/loggers.py +++ b/flytekit/loggers.py @@ -13,12 +13,6 @@ # By default, the root flytekit logger to debug so everything is logged, but enable fine-tuning logger = logging.getLogger("flytekit") -# Root logger control -flytekit_root_env_var = f"{LOGGING_ENV_VAR}_ROOT" -if os.getenv(flytekit_root_env_var) is not None: - logger.setLevel(int(os.getenv(flytekit_root_env_var))) -else: - logger.setLevel(logging.DEBUG) # Stop propagation so that configuration is isolated to this file (so that it doesn't matter what the # global Python root logger is set to). @@ -40,22 +34,33 @@ # create console handler ch = logging.StreamHandler() +ch.setLevel(logging.DEBUG) +# Root logger control # Don't want to import the configuration library since that will cause all sorts of circular imports, let's # just use the environment variable if it's defined. Decide in the future when we implement better controls # if we should control with the channel or with the logger level. # The handler log level controls whether log statements will actually print to the screen +flytekit_root_env_var = f"{LOGGING_ENV_VAR}_ROOT" level_from_env = os.getenv(LOGGING_ENV_VAR) +root_level_from_env = os.getenv(flytekit_root_env_var) if level_from_env is not None: - ch.setLevel(int(level_from_env)) + logger.setLevel(int(level_from_env)) +elif root_level_from_env is not None: + logger.setLevel(int(root_level_from_env)) else: - ch.setLevel(logging.WARNING) + logger.setLevel(logging.WARNING) for log_name, child_logger in child_loggers.items(): env_var = f"{LOGGING_ENV_VAR}_{log_name.upper()}" level_from_env = os.getenv(env_var) if level_from_env is not None: child_logger.setLevel(int(level_from_env)) + else: + if child_logger is user_space_logger: + child_logger.setLevel(logging.INFO) + else: + child_logger.setLevel(logging.WARNING) # create formatter formatter = jsonlogger.JsonFormatter(fmt="%(asctime)s %(name)s %(levelname)s %(message)s") From 3bc49c180ba7d39cc0bb3a72f498be8a54235013 Mon Sep 17 00:00:00 2001 From: Yee Hing Tong Date: Wed, 18 Jan 2023 17:37:48 -0800 Subject: [PATCH 2/2] flip the env var lookups Signed-off-by: Yee Hing Tong --- flytekit/loggers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flytekit/loggers.py b/flytekit/loggers.py index 465a47e1fb..f047348de0 100644 --- a/flytekit/loggers.py +++ b/flytekit/loggers.py @@ -44,10 +44,10 @@ flytekit_root_env_var = f"{LOGGING_ENV_VAR}_ROOT" level_from_env = os.getenv(LOGGING_ENV_VAR) root_level_from_env = os.getenv(flytekit_root_env_var) -if level_from_env is not None: - logger.setLevel(int(level_from_env)) -elif root_level_from_env is not None: +if root_level_from_env is not None: logger.setLevel(int(root_level_from_env)) +elif level_from_env is not None: + logger.setLevel(int(level_from_env)) else: logger.setLevel(logging.WARNING)