Files
Superalgos/utils/logger.js
T
mati108@gmail.com 6135d516db Container support
Changes required to accepts parameters and run the bots on the virtual machine.
2019-01-28 11:36:48 -03:00

40 lines
1.1 KiB
JavaScript

const winston = require('winston')
const appRoot = require('app-root-path')
const util = require('util')
const options = {
file: {
level: 'info',
filename: `${appRoot}/logs/app.log`,
handleExceptions: true,
json: true,
maxsize: 5242880, // 5MB
maxFiles: 5,
colorize: false,
timestamp: true
},
console: {
level: 'debug',
handleExceptions: true,
json: false,
colorize: true,
timestamp: true
}
}
exports.logger = winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.colorize(),
winston.format.splat(),
winston.format.timestamp({ format: 'YY/MM/DD HH:mm' }),
winston.format.printf(
info => `${info.timestamp} - ${info.level}: ${JSON.parse(JSON.stringify(util.inspect(info.message)))}`
)
),
transports: [
new winston.transports.File(options.file),
new winston.transports.Console(options.console)
],
exitOnError: false // do not exit on handled exceptions
})