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

Feat/diagnostic mode #18

Merged
merged 2 commits into from
Feb 24, 2022
Merged
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
12 changes: 10 additions & 2 deletions ovos_utils/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import sys
from os.path import join
from logging.handlers import RotatingFileHandler
from mycroft_bus_client.message import dig_for_message


class LOG:
Expand All @@ -38,6 +39,7 @@ class LOG:
backup_count = 3
name = 'OVOS'
level = "DEBUG"
diagnostic_mode = False
_loggers = {}

@classmethod
Expand All @@ -46,7 +48,8 @@ def init(cls, config=None):
cls.base_path = config.get("path", "stdout")
cls.max_bytes = config.get("max_bytes", 50000000)
cls.backup_count = config.get("backup_count", 3)
cls.level = config.get("level", "DEBUG")
cls.level = config.get("level", "INFO")
cls.diagnostic_mode = config.get("diagnostic", False)

@classmethod
def create_logger(cls, name, tostdout=False):
Expand Down Expand Up @@ -100,7 +103,12 @@ def _get_real_logger(cls):
module_name = mod.__name__ if mod else ''
name += module_name + ':' + record[3] + ':' + str(record[2])

return cls.create_logger(name)
logger = cls.create_logger(name)
if cls.diagnostic_mode:
msg = dig_for_message()
if msg:
logger.debug(f"DIAGNOSTIC - source bus message {msg.serialize()}")
return logger

@classmethod
def info(cls, *args, **kwargs):
Expand Down