Skip to content

Commit

Permalink
[API] Create logger handler once (#5488)
Browse files Browse the repository at this point in the history
  • Loading branch information
liranbg authored May 2, 2024
1 parent 6a1c128 commit 370acaf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mlrun/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,11 @@ def read_env(env=None, prefix=env_prefix):
log_formatter = mlrun.utils.create_formatter_instance(
mlrun.utils.FormatterKinds(log_formatter_name)
)
mlrun.utils.logger.get_handler("default").setFormatter(log_formatter)
current_handler = mlrun.utils.logger.get_handler("default")
current_formatter_name = current_handler.formatter.__class__.__name__
desired_formatter_name = log_formatter.__class__.__name__
if current_formatter_name != desired_formatter_name:
current_handler.setFormatter(log_formatter)

# The default function pod resource values are of type str; however, when reading from environment variable numbers,
# it converts them to type int if contains only number, so we want to convert them to str.
Expand Down

0 comments on commit 370acaf

Please sign in to comment.