Skip to content

Commit

Permalink
chore: enable file log
Browse files Browse the repository at this point in the history
  • Loading branch information
I-Want-ToBelieve committed Nov 25, 2023
1 parent 8052e71 commit 6c402f0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
1 change: 1 addition & 0 deletions apps/yakite-daemon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"krohnkite-core": "workspace:*",
"parse-json": "^8.0.0",
"winston": "^3.11.0",
"winston-daily-rotate-file": "^4.7.1",
"yakite-bridge": "workspace:*",
"yakite-config": "workspace:*",
"yakite-message": "workspace:*",
Expand Down
14 changes: 10 additions & 4 deletions apps/yakite-daemon/src/common/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createLogger, format, transports } from 'winston'
import { createLogger, format } from 'winston'
import DailyRotateFile from 'winston-daily-rotate-file'

const logLevels = {
fatal: 0,
Expand All @@ -12,9 +13,14 @@ const logLevels = {
const logger = createLogger({
format: format.combine(format.timestamp(), format.json()),
levels: logLevels,
transports: [new transports.Console()]
transports: [new DailyRotateFile({
dirname: '/tmp',
filename: 'yakite-daemon-%DATE%.log',
datePattern: 'YYYY-MM-DD-HH',
zippedArchive: false,
maxSize: '20m',
maxFiles: '14d'
})]
})

logger.close()

export default logger
31 changes: 31 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6c402f0

Please sign in to comment.