From 3093c16cb6fcdef78a4fa11eab0d23f8845cc865 Mon Sep 17 00:00:00 2001 From: JSHan94 Date: Wed, 3 Jan 2024 11:53:49 +0900 Subject: [PATCH] sanitize DailyRotateFile --- bots/src/lib/logger.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/bots/src/lib/logger.ts b/bots/src/lib/logger.ts index cf9c0d19..17cef1f1 100644 --- a/bots/src/lib/logger.ts +++ b/bots/src/lib/logger.ts @@ -2,14 +2,6 @@ import * as winston from 'winston'; import * as DailyRotateFile from 'winston-daily-rotate-file'; import { config } from 'config'; -function getLogsSubdir() { - const d = new Date(); - return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart( - 2, - '0' - )}-${String(d.getDate()).padStart(2, '0')}`; -} - function createLogger(name: string) { const formats = [winston.format.errors({ stack: true })]; @@ -35,13 +27,15 @@ function createLogger(name: string) { logger.add( new DailyRotateFile({ level: 'error', - filename: `logs/${getLogsSubdir()}/${name}_error.log`, + dirname: 'logs', + filename: `${name}_error.log`, zippedArchive: true }) ); logger.add( new DailyRotateFile({ - filename: `logs/${getLogsSubdir()}/${name}_combined.log`, + dirname: 'logs', + filename: `${name}_combined.log`, zippedArchive: true }) );