-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.js
33 lines (29 loc) · 818 Bytes
/
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
// File: logger.js
const winston = require('winston');
require('winston-daily-rotate-file');
const fileTransport = new winston.transports.DailyRotateFile({
filename: 'logs/discordbot-%DATE%.log',
datePattern: 'MM-DD-YYYY',
zippedArchive: true,
maxSize: '20m',
maxFiles: '14d',
level: 'info',
});
const logger = winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.timestamp({
format: () => {
return new Date().toLocaleString();
}
}),
winston.format.printf(({ timestamp, level, message }) => {
return `${timestamp} ${level}: ${message}`;
})
),
transports: [
fileTransport,
new winston.transports.Console(),
],
});
module.exports = logger;