Disable colors

This commit is contained in:
Pascal Perrenoud
2024-06-03 16:46:49 +02:00
parent 30c5797ed1
commit 337e5437d0
+7 -7
View File
@@ -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)