2016-09-29 21:09:36 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var bunyan = require('bunyan');
|
|
|
|
|
|
|
|
function BatchLogger (path) {
|
2016-10-03 19:28:13 +08:00
|
|
|
var stream = {
|
2016-10-12 07:40:35 +08:00
|
|
|
level: process.env.NODE_ENV === 'test' ? 'fatal' : 'info'
|
2016-10-03 19:28:13 +08:00
|
|
|
};
|
|
|
|
if (path) {
|
|
|
|
stream.path = path;
|
|
|
|
} else {
|
|
|
|
stream.stream = process.stdout;
|
|
|
|
}
|
2016-09-29 21:09:36 +08:00
|
|
|
this.path = path;
|
|
|
|
this.logger = bunyan.createLogger({
|
|
|
|
name: 'batch-queries',
|
2016-10-03 19:28:13 +08:00
|
|
|
streams: [stream]
|
2016-09-29 21:09:36 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = BatchLogger;
|
|
|
|
|
|
|
|
BatchLogger.prototype.log = function (job) {
|
2016-09-30 22:44:39 +08:00
|
|
|
return job.log(this.logger);
|
2016-09-29 21:09:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
BatchLogger.prototype.reopenFileStreams = function () {
|
|
|
|
this.logger.reopenFileStreams();
|
|
|
|
};
|