refactor(log): make BaseHandler abstract (#5737)

initial commit
This commit is contained in:
Tim Reichen 2024-08-22 08:46:53 +02:00 committed by GitHub
parent 833a24f088
commit afb9a4f336
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 4 deletions

View File

@ -16,7 +16,7 @@ export interface BaseHandlerOptions {
formatter?: FormatterFunction; formatter?: FormatterFunction;
} }
export class BaseHandler { export abstract class BaseHandler {
#levelName: LevelName; #levelName: LevelName;
#level: LogLevel; #level: LogLevel;
formatter: FormatterFunction; formatter: FormatterFunction;
@ -59,7 +59,7 @@ export class BaseHandler {
return this.formatter(logRecord); return this.formatter(logRecord);
} }
log(_msg: string) {} abstract log(msg: string): void;
setup() {} setup() {}
destroy() {} destroy() {}

View File

@ -52,7 +52,7 @@ export class ConsoleHandler extends BaseHandler {
return msg; return msg;
} }
override log(msg: string) { log(msg: string) {
console.log(msg); console.log(msg);
} }
} }

View File

@ -90,7 +90,7 @@ export class FileHandler extends BaseHandler {
} }
} }
override log(msg: string) { log(msg: string) {
const bytes = this[encoderSymbol].encode(msg + "\n"); const bytes = this[encoderSymbol].encode(msg + "\n");
if (bytes.byteLength > this[bufSymbol].byteLength - this[pointerSymbol]) { if (bytes.byteLength > this[bufSymbol].byteLength - this[pointerSymbol]) {
this.flush(); this.flush();