-
Notifications
You must be signed in to change notification settings - Fork 1
/
logger.js
44 lines (40 loc) · 1.03 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
const { createLogger, format, transports } = require('winston')
require('winston-daily-rotate-file');
const logger = createLogger({
format: format.combine(
format.timestamp(),
format.simple(),
format.printf(nfo => {
return `${nfo.timestamp} [${nfo.level}] : ${nfo.message}`;
})
),
exceptionHandlers: [
new transports.File({ filename: 'logs/exceptions.log' })
],
exitOnError: false,
transports: [
new transports.File({
filename: 'logs/error.log',
level: 'error',
}),
new transports.Console({
format: format.combine(
format.colorize(),
format.timestamp(),
format.simple(),
format.printf(nfo => {
return `${nfo.timestamp} [${nfo.level}] : ${nfo.message}`;
})
)
}),
new transports.DailyRotateFile({
filename: 'logs/TraderBirdBot-%DATE%.log',
datePattern: 'YYYY-MM-DD',
zippedArchive: false,
maxSize: '20m',
maxFiles: '14d',
level: 'debug'
})
]
});
module.exports = { logger };