From 1128d3afee5ccb7c65449adf02505714448c8bf2 Mon Sep 17 00:00:00 2001 From: Amin Sadeghi Date: Fri, 8 Mar 2024 15:18:57 -0500 Subject: [PATCH] Fix issue with logging scope (#2901) #bug --- openpnm/utils/__init__.py | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/openpnm/utils/__init__.py b/openpnm/utils/__init__.py index 1b52e093bd..b1036b9405 100644 --- a/openpnm/utils/__init__.py +++ b/openpnm/utils/__init__.py @@ -17,38 +17,13 @@ def _get_version(): from openpnm.__version__ import __version__ as ver + suffix = ".dev0" if ver.endswith(suffix): - ver = ver[:-len(suffix)] + ver = ver[: -len(suffix)] return ver -def _setup_logger(): - import os - import logging - # You can add info to the logger message by inserting the desired %(item) - # For a list of available items see: - # https://docs.python.org/3/library/logging.html#logrecord-attributes - # NOTE: If the calling locations appears as 'root' it's because the logger - # was not given a name in a file somewhere. A good option is __name__. - - try: - terminal_width = os.get_terminal_size().columns - except OSError: - terminal_width = 60 - column_width = terminal_width if terminal_width < 60 else 60 - - log_format = \ - '-' * column_width + '\n\ - - %(levelname)-7s: %(message)s \n\ - - SOURCE : %(name)s.%(funcName)s \n\ - - TIME : %(asctime)s\ - \n' + '-' * column_width - - logging.basicConfig(level=logging.WARNING, format=log_format) - del log_format - - def _setup_logger_rich(): import logging from rich.logging import RichHandler @@ -57,3 +32,6 @@ def _setup_logger_rich(): logging.basicConfig( format=FORMAT, datefmt="[%X]", handlers=[RichHandler(rich_tracebacks=True)] ) + + +_setup_logger_rich()