Skip to content

Commit

Permalink
Merge pull request #34 from synkd/fix_cli_log_level
Browse files Browse the repository at this point in the history
Make CLI respect log_level setting
  • Loading branch information
synkd authored Mar 18, 2024
2 parents 8ff1e29 + 87d5c61 commit c230772
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
7 changes: 1 addition & 6 deletions manifester/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

import logzero

from manifester.settings import settings


def setup_logzero(level="info", path="logs/manifester.log", silent=True):
"""Call logzero setup with the given settings."""
Expand All @@ -17,13 +15,10 @@ def setup_logzero(level="info", path="logs/manifester.log", silent=True):
log_level = getattr(logging, level.upper(), logging.INFO)
# formatter for terminal
formatter = logzero.LogFormatter(fmt=debug_fmt if log_level is logging.DEBUG else log_fmt)
logzero.setup_default_logger(formatter=formatter, disableStderrLogger=silent)
logzero.setup_logger(formatter=formatter, disableStderrLogger=silent)
logzero.loglevel(log_level)
# formatter for file
formatter = logzero.LogFormatter(
fmt=debug_fmt if log_level is logging.DEBUG else log_fmt, color=False
)
logzero.logfile(path, loglevel=log_level, maxBytes=1e9, backupCount=3, formatter=formatter)


setup_logzero(level=settings.get("log_level", "info"))
3 changes: 3 additions & 0 deletions manifester/manifester.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
simple_retry,
update_inventory,
)
from manifester.logger import setup_logzero
from manifester.settings import settings

setup_logzero(level=settings.get("log_level", "info"))


class Manifester:
"""Main Manifester class responsible for generating a manifest from the provided settings."""
Expand Down

0 comments on commit c230772

Please sign in to comment.