From afb9a4f3365a52cc75b6708da27b12ae3515ddf3 Mon Sep 17 00:00:00 2001 From: Tim Reichen Date: Thu, 22 Aug 2024 08:46:53 +0200 Subject: [PATCH] refactor(log): make `BaseHandler` abstract (#5737) initial commit --- log/base_handler.ts | 4 ++-- log/console_handler.ts | 2 +- log/file_handler.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/log/base_handler.ts b/log/base_handler.ts index 74e4f690e..8af7c0cd1 100644 --- a/log/base_handler.ts +++ b/log/base_handler.ts @@ -16,7 +16,7 @@ export interface BaseHandlerOptions { formatter?: FormatterFunction; } -export class BaseHandler { +export abstract class BaseHandler { #levelName: LevelName; #level: LogLevel; formatter: FormatterFunction; @@ -59,7 +59,7 @@ export class BaseHandler { return this.formatter(logRecord); } - log(_msg: string) {} + abstract log(msg: string): void; setup() {} destroy() {} diff --git a/log/console_handler.ts b/log/console_handler.ts index 1312e966b..810e14551 100644 --- a/log/console_handler.ts +++ b/log/console_handler.ts @@ -52,7 +52,7 @@ export class ConsoleHandler extends BaseHandler { return msg; } - override log(msg: string) { + log(msg: string) { console.log(msg); } } diff --git a/log/file_handler.ts b/log/file_handler.ts index cd4d72057..137595ae4 100644 --- a/log/file_handler.ts +++ b/log/file_handler.ts @@ -90,7 +90,7 @@ export class FileHandler extends BaseHandler { } } - override log(msg: string) { + log(msg: string) { const bytes = this[encoderSymbol].encode(msg + "\n"); if (bytes.byteLength > this[bufSymbol].byteLength - this[pointerSymbol]) { this.flush();