pastel.codes/config/winston.js

31 lines
645 B
JavaScript
Raw Permalink Normal View History

2020-06-22 21:46:41 +01:00
var winston = require('winston');
2020-06-22 22:53:27 +01:00
var appRoot = require('app-root-path');
2020-06-22 21:46:41 +01:00
2020-06-22 22:48:48 +01:00
var logger = new winston.createLogger({
transports: [
new winston.transports.File({
level: 'info',
filename: `${appRoot}/logs/app.log`,
handleExceptions: true,
json: true,
maxsize: 5242880, //5MB
maxFiles: 5,
colorize: false,
}),
new winston.transports.Console({
level: 'debug',
handleExceptions: true,
json: false,
colorize: true,
}),
],
exitOnError: false,
2020-06-22 21:46:41 +01:00
});
logger.stream = {
write: function (message, _encoding) {
logger.info(message);
},
2020-06-22 21:46:41 +01:00
};
module.exports = logger;