lamassu-server/lib/logger.js
Rafael Taranto de8a380bd8 Remove clutter from logger (#196)
* 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
2018-10-30 08:48:16 +02:00

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