-
Notifications
You must be signed in to change notification settings - Fork 9
/
logger.js
43 lines (36 loc) · 1.09 KB
/
logger.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
34
35
36
37
38
39
40
41
42
43
/* eslint linebreak-style: ["error", "windows"] */
const { createLogger, format, transports } = require('winston');
const {
combine, timestamp, prettyPrint, colorize,
} = format;
const myFormat = format.printf(info => `${info.timestamp} ${info.level}: ${info.message}`);
const riscoLogger = createLogger({
level: 'info',
format: combine(
// json(),
colorize(),
timestamp({ format: 'DD-MM-YYYY HH:mm:ss' }),
prettyPrint(),
myFormat,
),
transports: [
//
// - Write to all logs with level `info` and below to `combined.log`
// - Write all logs error (and below) to `error.log`.
//
new transports.File({ filename: 'logs/error.log', level: 'error' }),
new transports.File({ filename: 'logs/combined.log' }),
],
});
//
// If we're not in production then log to the `console` with the format:
// `${info.level}: ${info.message} JSON.stringify({ ...rest }) `
//
if (process.env.NODE_ENV !== 'production') {
riscoLogger.add(new transports.Console({
// format: format.simple(),
format: myFormat,
level: 'debug',
}));
}
module.exports = riscoLogger;