Minor changes to improve logger performance slightly and to lock down logging options in config
This commit is contained in:
parent
b3de8eaeb6
commit
0d17c388d8
2 changed files with 10 additions and 15 deletions
|
|
@ -7,6 +7,14 @@ const {
|
||||||
const Configuration = require('./Configuration');
|
const Configuration = require('./Configuration');
|
||||||
|
|
||||||
const LEVELS = ['error', 'warn', 'info', 'debug', 'verbose', 'silly'];
|
const LEVELS = ['error', 'warn', 'info', 'debug', 'verbose', 'silly'];
|
||||||
|
const LEVELS_LOOKUP = {
|
||||||
|
error: 'ERR',
|
||||||
|
warn: 'WRN',
|
||||||
|
info: 'INF',
|
||||||
|
debug: 'DBG',
|
||||||
|
verbose: 'VRB',
|
||||||
|
silly: 'SLY',
|
||||||
|
};
|
||||||
|
|
||||||
const logFormat = printf((info) => {
|
const logFormat = printf((info) => {
|
||||||
if (info.stack) {
|
if (info.stack) {
|
||||||
|
|
@ -35,20 +43,7 @@ class Logger {
|
||||||
const logger = winston.createLogger({
|
const logger = winston.createLogger({
|
||||||
format: combine(
|
format: combine(
|
||||||
winston.format((info) => {
|
winston.format((info) => {
|
||||||
switch (info.level) {
|
info.level = LEVELS_LOOKUP[info.level] || '???';
|
||||||
case 'warn':
|
|
||||||
info.level = 'WRN';
|
|
||||||
break;
|
|
||||||
case 'verbose':
|
|
||||||
info.level = 'VRB';
|
|
||||||
break;
|
|
||||||
case 'debug':
|
|
||||||
info.level = 'DBG';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
info.level = info.level.substring(0, 3).toUpperCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
})(),
|
})(),
|
||||||
timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
|
timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
"mqttUsername": "str",
|
"mqttUsername": "str",
|
||||||
"mqttPassword": "str",
|
"mqttPassword": "str",
|
||||||
"includeRoomsAsLights": "bool",
|
"includeRoomsAsLights": "bool",
|
||||||
"logLevel": "str",
|
"logLevel": "list(error|warn|info|debug|verbose|silly)",
|
||||||
"connectionTimeout": "int",
|
"connectionTimeout": "int",
|
||||||
"writeQueueWaitTime": "int"
|
"writeQueueWaitTime": "int"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue