[log_format] Add an option to change the log format (#3016)
* [log_format] Add an option to change the log format Hacing an option to change the log format could be useful when logs are shipped into an aggregator such as Elasticsearch. The current format is very hard to parse. * [log_format] Set default Formatter Because mycroft.configuration.Configuration() class import LOG class, a default Formatter have to be defined before import the mycroft.configuration.Configuration() class.feature/file-system
parent
34ee3a9a84
commit
0247b3a4b5
|
@ -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"],
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -85,6 +85,7 @@
|
|||
"test": false
|
||||
},
|
||||
"log_level": "DEBUG",
|
||||
"log_format": "{asctime} {levelname} {process} {name} {message}",
|
||||
"ignore_logs": ["enclosure.mouth.viseme"],
|
||||
"session": {
|
||||
"ttl": 180
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
"test": false
|
||||
},
|
||||
"log_level": "DEBUG",
|
||||
"log_format": "{asctime} {levelname} {process} {name} {message}",
|
||||
"ignore_logs": ["enclosure.mouth.viseme"],
|
||||
"session": {
|
||||
"ttl": 180
|
||||
|
|
Loading…
Reference in New Issue