Skip to content

Commit

Permalink
Merge branch 'mr/ramonat/e3-log-activate-once' into 'master'
Browse files Browse the repository at this point in the history
Ensure that e3.log.activate is run only once

See merge request it/e3-core!53
  • Loading branch information
enzbang committed Oct 21, 2024
2 parents 1a6bcce + ad318fe commit 045136f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/e3/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,22 @@ def activate(
) -> None:
"""Activate default E3 logging.
This function should be called only once. Subsequent calls will result
in a no-op.
:param level: set the root logger level to the specified level
:param datefmt: date/time format for the log handler
:param stream_format: format string for the stream handler
:param file_format: format string for the file handler
:param filename: redirect logs to a file in addition to the StreamHandler
:param e3_debug: activate full debug of the e3 library
"""
# Ensure that logs are not duplicated by mulitple calls to activate()
# e.g. this could be the case when running the testsuite with pytest xdist
if getattr(activate, "called_once", False):
return
else:
activate.called_once = True # type: ignore[attr-defined]
# By default do not filter anything. What is effectively logged
# will be defined by setting/unsetting handlers
logging.getLogger("").setLevel(logging.DEBUG)
Expand Down

0 comments on commit 045136f

Please sign in to comment.