diff --git a/python_boilerplate/configuration/loguru_configuration.py b/python_boilerplate/configuration/loguru_configuration.py index 9699b8e..727a137 100644 --- a/python_boilerplate/configuration/loguru_configuration.py +++ b/python_boilerplate/configuration/loguru_configuration.py @@ -41,8 +41,13 @@ compression="gz", serialize=False, ) -# Override the default stderr (console) -logger.add(sys.stderr, level=log_level, format=_message_format) +stderr = sys.stderr +if stderr is None: + logger.warning("Detected no-console mode") +else: + # Override the default stderr (console) if console is available + logger.add(stderr, level=log_level, format=_message_format) + logger.warning("Detected console mode") class InterceptHandler(logging.Handler): @@ -82,7 +87,7 @@ def emit(self, record: LogRecord) -> None: def retain_log_files() -> None: - now = arrow.get() + now = arrow.now("local") dates = { date.format("YYYY-MM-DD") for date in Arrow.range("day", now.shift(days=-7), end=now) diff --git a/setup.cfg b/setup.cfg index e328807..6111900 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = python_boilerplate -version = 7.1 +version = 7.2 description = A boilerplate project for Python. long_description = file: README.md long_description_content_type = text/markdown