This commit is contained in:
parent
7c8ef60d6a
commit
878532997b
41
log/index.ts
41
log/index.ts
@ -4,24 +4,6 @@ import winston, { format } from "winston"
|
|||||||
|
|
||||||
const isProd = process.env.NODE_ENV === "production"
|
const isProd = process.env.NODE_ENV === "production"
|
||||||
|
|
||||||
const dailyRotateFileTransport4Info = new winston.transports.DailyRotateFile({
|
|
||||||
level: "info",
|
|
||||||
filename: "/home/work/log/egg-info-%DATE%.log",
|
|
||||||
datePattern: "YYYY-MM-DD",
|
|
||||||
zippedArchive: true,
|
|
||||||
maxSize: "20m",
|
|
||||||
maxFiles: "14d",
|
|
||||||
})
|
|
||||||
|
|
||||||
const dailyRotateFileTransport4Debug = new winston.transports.DailyRotateFile({
|
|
||||||
level: "debug",
|
|
||||||
filename: "/home/work/log/egg-debug-%DATE%.log",
|
|
||||||
datePattern: "YYYY-MM-DD",
|
|
||||||
zippedArchive: true,
|
|
||||||
maxSize: "20m",
|
|
||||||
maxFiles: "14d",
|
|
||||||
})
|
|
||||||
|
|
||||||
const transports: any[] = [
|
const transports: any[] = [
|
||||||
new winston.transports.Console({
|
new winston.transports.Console({
|
||||||
level: "info",
|
level: "info",
|
||||||
@ -29,8 +11,27 @@ const transports: any[] = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
if (isProd) {
|
if (isProd) {
|
||||||
transports.push(dailyRotateFileTransport4Info)
|
const config = {
|
||||||
transports.push(dailyRotateFileTransport4Debug)
|
datePattern: "YYYY-MM-DD",
|
||||||
|
zippedArchive: true,
|
||||||
|
maxSize: "20m",
|
||||||
|
maxFiles: "14d",
|
||||||
|
}
|
||||||
|
|
||||||
|
transports.push(
|
||||||
|
new winston.transports.DailyRotateFile({
|
||||||
|
level: "info",
|
||||||
|
filename: "/home/work/log/egg-info-%DATE%.log",
|
||||||
|
...config,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
transports.push(
|
||||||
|
new winston.transports.DailyRotateFile({
|
||||||
|
level: "debug",
|
||||||
|
filename: "/home/work/log/egg-debug-%DATE%.log",
|
||||||
|
...config,
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const loggerIns = winston.createLogger({
|
const loggerIns = winston.createLogger({
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "bun run index.ts",
|
"start": "bun run index.ts",
|
||||||
|
"dev": "NODE_ENV=dev bun run index.ts --watch",
|
||||||
"lint": "eslint --fix .",
|
"lint": "eslint --fix .",
|
||||||
"prepare": "husky",
|
"prepare": "husky",
|
||||||
"prettier": "prettier --write ."
|
"prettier": "prettier --write ."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user