Skip to content

Commit

Permalink
sanitize DailyRotateFile
Browse files Browse the repository at this point in the history
  • Loading branch information
JSHan94 committed Jan 3, 2024
1 parent c77f82b commit 3093c16
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions bots/src/lib/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })];

Expand All @@ -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
})
);
Expand Down

0 comments on commit 3093c16

Please sign in to comment.