Skip to content

Commit

Permalink
Use default logger if fail to initialize RichHandler (#2423)
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Su <[email protected]>
  • Loading branch information
pingsutw authored May 28, 2024
1 parent f8355b3 commit 88ee93e
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions flytekit/loggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ def initialize_global_loggers():
"""
Initializes the global loggers to the default configuration.
"""
# Use Rich logging while running in the local execution
if os.environ.get("FLYTE_INTERNAL_EXECUTION_ID", None) is None:
upgrade_to_rich_logging()
return

handler = logging.StreamHandler()
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter(fmt="[%(name)s] %(message)s")
Expand All @@ -98,6 +93,10 @@ def initialize_global_loggers():
set_flytekit_log_properties(handler, None, _get_env_logging_level())
set_user_logger_properties(handler, None, logging.INFO)

# Use Rich logging while running in the local execution
if os.environ.get("FLYTE_INTERNAL_EXECUTION_ID", None) is None or interactive.ipython_check():
upgrade_to_rich_logging()


def is_rich_logging_enabled() -> bool:
return os.environ.get(LOGGING_RICH_FMT_ENV_VAR) != "0"
Expand Down Expand Up @@ -146,8 +145,5 @@ def get_level_from_cli_verbosity(verbosity: int) -> int:
return logging.DEBUG


if interactive.ipython_check():
upgrade_to_rich_logging()
else:
# Default initialization
initialize_global_loggers()
# Default initialization
initialize_global_loggers()

0 comments on commit 88ee93e

Please sign in to comment.