const utils = require('./utils.js'); // 时间格式化函数
const bunyan = require("bunyan");
const log = bunyan.createLogger({
name: 'app',
streams: [
{
level: 'error',
stream:new MyRawStream(),
type:'raw'
}
]
});
function MyRawStream() {}
MyRawStream.prototype.write=function (rec) {
rec.time = utils.formatTime(new Date(rec.time), 'yyyy-MM-dd hh:mm:ss');
rec.level = bunyan.nameFromLevel[rec.level];
console.error(JSON.stringify(rec));
}