From 337e5437d0ecd508ca5a0b55b3efb2482b97bed7 Mon Sep 17 00:00:00 2001 From: Pascal Perrenoud Date: Mon, 3 Jun 2024 16:46:49 +0200 Subject: [PATCH] Disable colors --- index.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/index.ts b/index.ts index f28a646..ab50aea 100644 --- a/index.ts +++ b/index.ts @@ -10,26 +10,26 @@ export class DailyFile implements Writer { private readonly folder: string private current_date: Date = new Date() - public constructor(options: WriterOptions & {folder: string}) { - const {folder, ...rest} = options + public constructor(options: {minLevel: Level, folder: string}) { + const {folder, minLevel} = options - this._options = rest + this._options = {minLevel, with_color: false} this.folder = folder - this.writer = DailyFile.start(this.options, this.folder, this.current_date) + this.writer = DailyFile.start(this._options.minLevel, this.folder, this.current_date) } - private static start(options: WriterOptions, folder: string, now: Date) : File { + private static start(minLevel: Level, folder: string, now: Date) : File { const date = now.toISOString().split('T')[0] const path = `${folder}/${date}.log` - return new File({...options, path}) + return new File({minLevel, path}) } public log(level: Level, ...data: any[]): void { if (new Date().getDay() !== this.current_date.getDay()) { this.current_date = new Date() this.writer.end() - this.writer = DailyFile.start(this._options, this.folder, this.current_date) + this.writer = DailyFile.start(this._options.minLevel, this.folder, this.current_date) } return this.writer.log(level, data)