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;
}
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() {}

View File

@ -52,7 +52,7 @@ export class ConsoleHandler extends BaseHandler {
return msg;
}
override log(msg: string) {
log(msg: string) {
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");
if (bytes.byteLength > this[bufSymbol].byteLength - this[pointerSymbol]) {
this.flush();