mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2024-11-17 02:48:31 -07:00
26 lines
897 B
JavaScript
26 lines
897 B
JavaScript
const winston = require('winston');
|
|
const data = require('./data');
|
|
|
|
const logger = new (winston.Logger)({
|
|
transports: [
|
|
new (winston.transports.File)({
|
|
filename: data.joinPath('log.txt'),
|
|
json: false,
|
|
level: winston.level.info,
|
|
maxFiles: 3,
|
|
maxsize: 10000000, // 10MB
|
|
}),
|
|
new (winston.transports.Console)({
|
|
timestamp: () => new Date().toLocaleString(),
|
|
formatter: function(options) {
|
|
return options.timestamp() + ' ' +
|
|
winston.config.colorize(options.level, options.level.toUpperCase()) + ' ' +
|
|
(options.message ? options.message : '') +
|
|
(options.meta && Object.keys(options.meta).length ? '\n\t'+ JSON.stringify(options.meta) : '' );
|
|
}
|
|
})
|
|
]
|
|
});
|
|
|
|
module.exports = logger;
|