Skip to content

Commit

Permalink
fix($log): retain log files by local date; override the default stder…
Browse files Browse the repository at this point in the history
…r (console) if console is available

hotfix/7.2

[skip ci]
  • Loading branch information
johnnymillergh committed Nov 4, 2023
1 parent 6fc72b9 commit a8009b1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions python_boilerplate/configuration/loguru_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit a8009b1

Please sign in to comment.