-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
33 lines (31 loc) · 907 Bytes
/
index.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
29
30
31
32
33
const winston = require('winston');
class Logger {
constructor() {
const formats = {
flat: winston.format.combine(
winston.format.colorize(),
winston.format.timestamp(),
winston.format.align(),
winston.format.printf(info => `${info.timestamp} ${info.level}: ${info.message}`)
),
json: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
)
};
const logFormat = process.env.LOG_FORMAT && formats[process.env.LOG_FORMAT] ? formats[process.env.LOG_FORMAT] : formats.json;
const logLevel = process.env.LOG_LEVEL || 'verbose';
winston.configure({
format: logFormat,
level: logLevel,
transports: [
new (winston.transports.Console)({
handleExceptions: false
})
],
exitOnError: false
});
return winston;
}
}
module.exports = Logger;