diff --git a/mycroft/configuration/mycroft.conf b/mycroft/configuration/mycroft.conf index b6922259aa..67dc2aee7b 100644 --- a/mycroft/configuration/mycroft.conf +++ b/mycroft/configuration/mycroft.conf @@ -263,6 +263,14 @@ // If not defined, the default log level is INFO. //"log_level": "INFO", + // Format of logs to store. + // NOTE: This configuration setting is special and can only be changed in the + // SYSTEM or USER configuration file, it will not be read if defined in the + // DEFAULT (here) or in the REMOTE mycroft config. + // If not defined, the default log format is: + // {asctime} | {levelname:8} | {process:5} | {name} | {message} + //"log_format": "{asctime} | {levelname:8} | {process:5} | {name} | {message}", + // Messagebus types that will NOT be output to logs "ignore_logs": ["enclosure.mouth.viseme", "enclosure.mouth.display"], diff --git a/mycroft/util/log.py b/mycroft/util/log.py index b000f0ff01..5894784e89 100644 --- a/mycroft/util/log.py +++ b/mycroft/util/log.py @@ -87,6 +87,10 @@ class LOG: cls.handler.setFormatter(formatter) config = mycroft.configuration.Configuration.get(remote=False) + if config.get('log_format'): + formatter = logging.Formatter(config.get('log_format'), style='{') + cls.handler.setFormatter(formatter) + cls.level = logging.getLevelName(config.get('log_level', 'INFO')) # Enable logging in external modules diff --git a/test/unittests/util/commented.json b/test/unittests/util/commented.json index 00a581f6df..b7fed8a813 100644 --- a/test/unittests/util/commented.json +++ b/test/unittests/util/commented.json @@ -85,6 +85,7 @@ "test": false }, "log_level": "DEBUG", + "log_format": "{asctime} {levelname} {process} {name} {message}", "ignore_logs": ["enclosure.mouth.viseme"], "session": { "ttl": 180 diff --git a/test/unittests/util/plain.json b/test/unittests/util/plain.json index eec84631d8..746fc7bb40 100644 --- a/test/unittests/util/plain.json +++ b/test/unittests/util/plain.json @@ -67,6 +67,7 @@ "test": false }, "log_level": "DEBUG", + "log_format": "{asctime} {levelname} {process} {name} {message}", "ignore_logs": ["enclosure.mouth.viseme"], "session": { "ttl": 180