-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogManager.js
28 lines (25 loc) · 928 Bytes
/
logManager.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var winston = require('winston');
class logManager {
constructor(configuration) {
this.logger = new (winston.createLogger)({
transports: [
new (winston.transports.Console)({ json: false, timestamp: true }),
new winston.transports.File({ filename: __dirname + '/logs/debug.log', json: false })
],
exceptionHandlers: [
new (winston.transports.Console)({ json: false, timestamp: true }),
new winston.transports.File({ filename: __dirname + '/logs/exceptions.log', json: false })
],
format: winston.format.combine(winston.format.timestamp(), winston.format.json()),
exitOnError: false
});
var environment = configuration.getCurrentEnvironment();
if (environment == 'production') {
this.logger.level = 'error';
}
else if (environment == 'development') {
this.logger.level = 'debug';
}
}
}
module.exports = logManager;