CartoDB-SQL-API-1.47.2/batch/batch-logger.js
2023-05-07 23:04:18 +08:00

30 lines
612 B
JavaScript

'use strict';
var bunyan = require('bunyan');
function BatchLogger (path) {
var stream = {
level: process.env.NODE_ENV === 'test' ? 'fatal' : 'info'
};
if (path) {
stream.path = path;
} else {
stream.stream = process.stdout;
}
this.path = path;
this.logger = bunyan.createLogger({
name: 'batch-queries',
streams: [stream]
});
}
module.exports = BatchLogger;
BatchLogger.prototype.log = function (job) {
return job.log(this.logger);
};
BatchLogger.prototype.reopenFileStreams = function () {
this.logger.reopenFileStreams();
};