first commit
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
|
||||
const bunyan = require('bunyan');
|
||||
|
||||
class Logger {
|
||||
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);
|
||||
}
|
||||
|
||||
reopenFileStreams () {
|
||||
console.log('Reloading log file', this.path);
|
||||
this.logger.reopenFileStreams();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Logger;
|
||||
Reference in New Issue
Block a user