Skip to content

Commit

Permalink
Cleanup standard logging and fix bug where level was not applied (#265)
Browse files Browse the repository at this point in the history
Co-authored-by: Aart Stuurman <[email protected]>
  • Loading branch information
surgura and Aart Stuurman committed Sep 11, 2023
1 parent 35626b4 commit 05c2f47
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions standard_resources/revolve2/standard_resources/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,12 @@ def setup_logging(level: int = logging.INFO, file_name: str | None = None) -> No
# By default, we are interested in messages of level 'info' and the more severe 'warning', 'error', and 'critical',
# and we exclude the less severe 'debug'.
# Furthermore, we specify the format in which we want the messages to be printed.
if file_name is None:
logging.basicConfig(
level=logging.INFO,
format="[%(asctime)s] [%(levelname)s] [%(module)s] %(message)s",
)
else:
logging.basicConfig(
level=logging.INFO,
format="[%(asctime)s] [%(levelname)s] [%(module)s] %(message)s",
handlers=[logging.FileHandler(file_name), logging.StreamHandler()],
)
logging.basicConfig(
level=level,
format="[%(asctime)s] [%(levelname)s] [%(module)s] %(message)s",
)
if file_name is not None:
logging.root.handlers.append(logging.FileHandler(file_name))
logging.info("=======================================")
logging.info("=======================================")
logging.info("=======================================")
Expand Down

0 comments on commit 05c2f47

Please sign in to comment.