forked from inf-xu/ffmeg-m4s
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlogger.js
32 lines (31 loc) · 930 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
const { createLogger, format, transports } = require("winston");
const customFormat = format.combine(
format.timestamp({ format: "MMM-DD-YYYY HH:mm:ss" }),
// format.align(),
format.printf((i) => `${i.level}: ${[i.timestamp]}: ${i.message}`)
);
const customFormatSimple = format.combine(
format.timestamp({ format: "MMM-DD-YYYY HH:mm:ss" }),
format.printf((i) => `${i.message}`)
);
const defaultOptions = {
format: customFormat,
};
module.exports = createLogger({
transports: [
new transports.Console({
level: "debug",
format: customFormatSimple, //format.simple(),
}),
new transports.File({
filename: "logs/debug.log",
level: "debug",
...defaultOptions,
}),
new transports.File({
filename: "logs/error.log",
level: "error",
...defaultOptions,
})
],
});