* Remove clutter from the logger Prior to this commit the logger was stringfying even functions. Because of this response errors from axios was dumping a log of info on the logs. * Fixing standard style issues * Check for toString on meta
22 lines
504 B
JavaScript
22 lines
504 B
JavaScript
const winston = require('winston')
|
|
const options = require('./options')
|
|
const _ = require('lodash')
|
|
|
|
const logger = new winston.Logger({
|
|
level: options.logLevel,
|
|
transports: [
|
|
new (winston.transports.Console)({ timestamp: true, colorize: true })
|
|
],
|
|
rewriters: [
|
|
(...[,, meta]) => _.hasIn('toString', meta)
|
|
? meta.toString() : 'Error, no further information is available'
|
|
]
|
|
})
|
|
|
|
logger.stream = {
|
|
write: message => {
|
|
logger.info(message.trim())
|
|
}
|
|
}
|
|
|
|
module.exports = logger
|