CartoDB-SQL-API/batch/batch-logger.js
2016-09-30 16:44:39 +02:00

26 lines
579 B
JavaScript

'use strict';
var bunyan = require('bunyan');
var fs = require('fs');
function BatchLogger (path) {
this.path = path;
this.logger = bunyan.createLogger({
name: 'batch-queries',
streams: [{
level: 'info',
stream: path ? fs.createWriteStream(path, { flags: 'a', encoding: 'utf8' }) : process.stdout
}]
});
}
module.exports = BatchLogger;
BatchLogger.prototype.log = function (job) {
return job.log(this.logger);
};
BatchLogger.prototype.reopenFileStreams = function () {
this.logger.reopenFileStreams();
};