refactor(logger): Refactor logger.js

Use class style implement write interface
This commit is contained in:
BoHong Li 2017-03-19 01:21:43 +08:00 committed by Raccoon Li
parent 90631df2ba
commit 036b2414f3
1 changed files with 11 additions and 11 deletions

View File

@ -1,23 +1,23 @@
'use strict'
var winston = require('winston')
winston.emitErrs = true
const winston = require('winston')
var logger = new winston.Logger({
class Logger extends winston.Logger {
// Implement stream.writable.write interface
write (chunk) {
this.info(chunk)
}
}
module.exports = new Logger({
transports: [
new winston.transports.Console({
level: 'debug',
handleExceptions: true,
json: false,
colorize: true,
colorize: false,
timestamp: true
})
],
emitErrs: true,
exitOnError: false
})
module.exports = logger
module.exports.stream = {
write: function (message, encoding) {
logger.info(message)
}
}