CartoDB-SQL-API/app/services/bunyan_logger.js
2018-05-28 11:18:30 +02:00

34 lines
650 B
JavaScript

'use strict';
const bunyan = require('bunyan');
class BunyanLogger {
constructor (path, name) {
const 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,
streams: [stream]
});
}
info (log, message) {
this.logger.info(log, message);
}
warn (log, message) {
this.logger.warn(log, message);
}
}
module.exports = BunyanLogger;