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({
|
2024-04-29 13:21:31 +01:00
|
|
|
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 = {
|
2024-04-29 13:21:31 +01:00
|
|
|
write: function (message, _encoding) {
|
|
|
|
logger.info(message);
|
|
|
|
},
|
2020-06-22 21:46:41 +01:00
|
|
|
};
|
2024-04-29 13:21:31 +01:00
|
|
|
module.exports = logger;
|