-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.js
More file actions
29 lines (27 loc) · 910 Bytes
/
log.js
File metadata and controls
29 lines (27 loc) · 910 Bytes
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
let winston = require("winston");
const colorizer = winston.format.colorize();
const { createLogger, format } = require("winston");
const { combine, timestamp, prettyPrint, label } = format;
let logger;
if (process.env.NODE_ENV === "development") {
logger = createLogger({
format: combine(
label({ label: "DEVELOPMENT" }),
timestamp({ format: "YYYY-MM-DD HH:mm:ss" }),
format.json(),
winston.format.simple(),
winston.format.printf(msg =>
colorizer.colorize(
msg.level,`${msg.label} - ${msg.level} - ${msg.message} - ${msg.timestamp} `
)
)
),
transports: [new winston.transports.Console()]
});
} else {
logger = createLogger({
format: combine(label({ label: "WEB RTC" }), timestamp(), winston.format.json()),
transports: [new winston.transports.File({ filename: "./logs/combined.log" })]
});
}
module.exports = logger;