Skip to content

Commit

Permalink
logger: Allows for disabling loggin to buffer
Browse files Browse the repository at this point in the history
* Allows disable logger to avoid filling buffer when using as lib
  • Loading branch information
JoaoMario109 committed Jul 24, 2024
1 parent 749b27a commit e978976
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions blueos_repository/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,17 @@ class Logger:
Simple logger class to consolidate logs and generate a manifest.log
"""

enabled: bool = True
log_buffer: ManifestLog = ManifestLog()

@staticmethod
def disable() -> None:
Logger.enabled = False

@staticmethod
def enable() -> None:
Logger.enabled = True

@staticmethod
def start_docker_rate_limit(rate_limit: RateLimit) -> None:
"""
Expand Down Expand Up @@ -80,6 +89,9 @@ def _check_and_init_entry(entry: str) -> None:

@staticmethod
def log(entry: str, message: str, level: LogEntryStatus) -> None:
if not Logger.enabled:
return

Logger._check_and_init_entry(entry)
Logger.log_buffer.extensions[entry].append(LogEntry(level, message))

Expand Down

0 comments on commit e978976

Please sign in to comment.