-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.mjs
39 lines (37 loc) · 1.25 KB
/
logger.mjs
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
// LOGGING CONFIGURATION | AUSTIN GINN 2023
import winston from 'winston';
import DailyRotateFile from 'winston-daily-rotate-file';
const logger = winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.timestamp(), // Add a timestamp to log messages
winston.format.json()
),
defaultMeta: { service: 'tcl-automation' },
transports: [
new DailyRotateFile({
filename: 'logs/tcl-automation-%DATE%.log',
datePattern: 'YYYY-MM-DD',
zippedArchive: true,
maxSize: '20m',
maxFiles: '14d',
level: 'error',
format: winston.format.combine(
winston.format.timestamp(), // Add a timestamp to log messages
winston.format.json()
),
}),
new DailyRotateFile({
filename: 'logs/tcl-automation-%DATE%-combined.log',
datePattern: 'YYYY-MM-DD',
zippedArchive: true,
maxSize: '20m',
maxFiles: '14d',
format: winston.format.combine(
winston.format.timestamp(), // Add a timestamp to log messages
winston.format.json()
),
}),
]
});
export default logger;