-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.js
27 lines (24 loc) · 843 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
const path = require("path")
const winston = require("winston")
const DailyRotateFile = require("winston-daily-rotate-file")
const filePath = process.argv[2] || "./logs"
const logLevel = process.env.LOG_LEVEL || "info"
const logger = winston.createLogger({
level: logLevel,
format: winston.format.combine(
winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }),
winston.format.printf(({ timestamp, level, message }) => {
return `${timestamp} [${level.toUpperCase()}]: ${message}`
})
),
transports: [
new winston.transports.Console(),
new DailyRotateFile({
filename: path.join(filePath, "redirecterr-%DATE%.log"),
datePattern: "YYYY-MM-DD",
maxSize: "500k",
maxFiles: "7d",
}),
],
})
module.exports = logger