Skip to content

Commit 4b3633a

Browse files
authored
Feat/diagnostic mode (#18)
* feat/diagnostic_mode authored-by: jarbasai <jarbasai@mailfence.com>
1 parent e136afe commit 4b3633a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

ovos_utils/log.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import sys
1717
from os.path import join
1818
from logging.handlers import RotatingFileHandler
19+
from mycroft_bus_client.message import dig_for_message
1920

2021

2122
class LOG:
@@ -38,6 +39,7 @@ class LOG:
3839
backup_count = 3
3940
name = 'OVOS'
4041
level = "DEBUG"
42+
diagnostic_mode = False
4143
_loggers = {}
4244

4345
@classmethod
@@ -46,7 +48,8 @@ def init(cls, config=None):
4648
cls.base_path = config.get("path", "stdout")
4749
cls.max_bytes = config.get("max_bytes", 50000000)
4850
cls.backup_count = config.get("backup_count", 3)
49-
cls.level = config.get("level", "DEBUG")
51+
cls.level = config.get("level", "INFO")
52+
cls.diagnostic_mode = config.get("diagnostic", False)
5053

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

103-
return cls.create_logger(name)
106+
logger = cls.create_logger(name)
107+
if cls.diagnostic_mode:
108+
msg = dig_for_message()
109+
if msg:
110+
logger.debug(f"DIAGNOSTIC - source bus message {msg.serialize()}")
111+
return logger
104112

105113
@classmethod
106114
def info(cls, *args, **kwargs):

0 commit comments

Comments
 (0)