diff --git a/apps/yakite-daemon/package.json b/apps/yakite-daemon/package.json index 253fd35..4dff6a6 100644 --- a/apps/yakite-daemon/package.json +++ b/apps/yakite-daemon/package.json @@ -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:*", diff --git a/apps/yakite-daemon/src/common/logger.ts b/apps/yakite-daemon/src/common/logger.ts index 8b4e880..8c94db9 100644 --- a/apps/yakite-daemon/src/common/logger.ts +++ b/apps/yakite-daemon/src/common/logger.ts @@ -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, @@ -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 diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c40de0b..4528140 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -135,6 +135,9 @@ importers: winston: specifier: ^3.11.0 version: 3.11.0 + winston-daily-rotate-file: + specifier: ^4.7.1 + version: 4.7.1(winston@3.11.0) yakite-bridge: specifier: workspace:* version: link:../yakite-bridge @@ -3148,6 +3151,12 @@ packages: flat-cache: 3.2.0 dev: false + /file-stream-rotator@0.6.1: + resolution: {integrity: sha512-u+dBid4PvZw17PmDeRcNOtCP9CCK/9lRN2w+r1xIS7yOL9JFrIBKTvrYsxT4P0pGtThYTn++QS5ChHaUov3+zQ==} + dependencies: + moment: 2.29.4 + dev: false + /fill-range@7.0.1: resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==} engines: {node: '>=8'} @@ -4253,6 +4262,10 @@ packages: engines: {node: '>= 8.0.0'} dev: false + /moment@2.29.4: + resolution: {integrity: sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==} + dev: false + /ms@2.1.2: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} dev: false @@ -4340,6 +4353,11 @@ packages: engines: {node: '>=0.10.0'} dev: false + /object-hash@2.2.0: + resolution: {integrity: sha512-gScRMn0bS5fH+IuwyIFgnh9zBdo4DV+6GhygmWM9HyNJSgS0hScp1f5vjtm7oIIOiT9trXrShAkLFSc2IqKNgw==} + engines: {node: '>= 6'} + dev: false + /object-inspect@1.13.1: resolution: {integrity: sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==} dev: false @@ -5947,6 +5965,19 @@ packages: string-width: 4.2.3 dev: false + /winston-daily-rotate-file@4.7.1(winston@3.11.0): + resolution: {integrity: sha512-7LGPiYGBPNyGHLn9z33i96zx/bd71pjBn9tqQzO3I4Tayv94WPmBNwKC7CO1wPHdP9uvu+Md/1nr6VSH9h0iaA==} + engines: {node: '>=8'} + peerDependencies: + winston: ^3 + dependencies: + file-stream-rotator: 0.6.1 + object-hash: 2.2.0 + triple-beam: 1.4.1 + winston: 3.11.0 + winston-transport: 4.6.0 + dev: false + /winston-transport@4.6.0: resolution: {integrity: sha512-wbBA9PbPAHxKiygo7ub7BYRiKxms0tpfU2ljtWzb3SjRjv5yl6Ozuy/TkXf00HTAt+Uylo3gSkNwzc4ME0wiIg==} engines: {node: '>= 12.0.0'}