Skip to content

Commit

Permalink
Fix issue with logging scope (#2901) #bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ma-sadeghi authored Mar 8, 2024
1 parent c6724b9 commit 1128d3a
Showing 1 changed file with 5 additions and 27 deletions.
32 changes: 5 additions & 27 deletions openpnm/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -57,3 +32,6 @@ def _setup_logger_rich():
logging.basicConfig(
format=FORMAT, datefmt="[%X]", handlers=[RichHandler(rich_tracebacks=True)]
)


_setup_logger_rich()

0 comments on commit 1128d3a

Please sign in to comment.