refactor(logger): Refactor logger.js
Use class style implement write interface
This commit is contained in:
parent
90631df2ba
commit
036b2414f3
1 changed files with 11 additions and 11 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue