diff --git a/log/base_handler.ts b/log/base_handler.ts index 0f51d0f278f6..2a3bde8829b2 100644 --- a/log/base_handler.ts +++ b/log/base_handler.ts @@ -50,14 +50,20 @@ export class BaseHandler { if (this.level > logRecord.level) return; const msg = this.format(logRecord); - this.log(msg); + this.#log(msg); } format(logRecord: LogRecord): string { return this.formatter(logRecord); } + /** + * @deprecated (will be removed in 0.220.0) + */ log(_msg: string) {} + #log(msg: string) { + this.log(msg); + } setup() {} destroy() {} diff --git a/log/console_handler.ts b/log/console_handler.ts index 8625652e8628..e92cc358f26f 100644 --- a/log/console_handler.ts +++ b/log/console_handler.ts @@ -24,12 +24,17 @@ export class ConsoleHandler extends BaseHandler { let msg = super.format(logRecord); if (this.#useColors) { - msg = this.applyColors(msg, logRecord.level); + msg = this.#applyColors(msg, logRecord.level); } return msg; } - + #applyColors(msg: string, level: number): string { + return this.applyColors(msg, level); + } + /** + * @deprecated (will be removed in 0.220.0) + */ applyColors(msg: string, level: number): string { switch (level) { case LogLevels.INFO: @@ -51,7 +56,7 @@ export class ConsoleHandler extends BaseHandler { return msg; } - override log(msg: string) { + override #log(msg: string) { console.log(msg); } } diff --git a/log/file_handler.ts b/log/file_handler.ts index f265e13cd42e..ce02a2620e42 100644 --- a/log/file_handler.ts +++ b/log/file_handler.ts @@ -85,6 +85,13 @@ export class FileHandler extends BaseHandler { } } + #flush() { + this.#flush(); + } + + /** + * @deprecated (will be removed in 0.220.0) + */ flush() { if (this._pointer > 0 && this._file) { let written = 0; diff --git a/log/logger.ts b/log/logger.ts index bf68f081b6c2..37dd162ab1b1 100644 --- a/log/logger.ts +++ b/log/logger.ts @@ -120,9 +120,9 @@ export class Logger { let logMessage: string; if (msg instanceof Function) { fnResult = msg(); - logMessage = this.asString(fnResult); + logMessage = this.#asString(fnResult); } else { - logMessage = this.asString(msg); + logMessage = this.#asString(msg); } const record: LogRecord = new LogRecord({ msg: logMessage, @@ -138,6 +138,12 @@ export class Logger { return msg instanceof Function ? fnResult : msg; } + #asString(data: unknown, isProperty = false): string { + return this.asString(data, isProperty); + } + /** + * @deprecated (will be removed in 0.220.0) + */ asString(data: unknown, isProperty = false): string { if (typeof data === "string") { if (isProperty) return `"${data}"`; @@ -156,7 +162,7 @@ export class Logger { } else if (typeof data === "object") { return `{${ Object.entries(data) - .map(([k, v]) => `"${k}":${this.asString(v, true)}`) + .map(([k, v]) => `"${k}":${this.#asString(v, true)}`) .join(",") }}`; } diff --git a/log/rotating_file_handler.ts b/log/rotating_file_handler.ts index 5255951f60cb..186fd0c56200 100644 --- a/log/rotating_file_handler.ts +++ b/log/rotating_file_handler.ts @@ -99,7 +99,7 @@ export class RotatingFileHandler extends FileHandler { const msgByteLength = this._encoder.encode(msg).byteLength + 1; if (this.#currentFileSize + msgByteLength > this.#maxBytes) { - this.rotateLogFiles(); + this.#rotateLogFiles(); this.#currentFileSize = 0; } @@ -107,7 +107,12 @@ export class RotatingFileHandler extends FileHandler { this.#currentFileSize += msgByteLength; } - + #rotateLogFiles() { + this.rotateLogFiles(); + } + /** + * @deprecated (will be removed in 0.220.0) + */ rotateLogFiles() { this.flush(); this._file!.close();