Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make CLI respect log_level setting #34

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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