From 504afe7afe3608832b83d61c56a81c6f8149e53c Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Thu, 11 Apr 2024 19:25:18 +0900 Subject: [PATCH] fix(log): Revert "deprecate(log): deprecate internal utility methods (#4436)" This reverts commit 42df58a2331f6c028d71a2082809583793ee2442. --- log/base_handler.ts | 8 +------- log/console_handler.ts | 11 +++-------- log/file_handler.ts | 7 ------- log/logger.ts | 12 +++--------- log/rotating_file_handler.ts | 9 ++------- 5 files changed, 9 insertions(+), 38 deletions(-) diff --git a/log/base_handler.ts b/log/base_handler.ts index 61f56c014680..7dc87ab74f5e 100644 --- a/log/base_handler.ts +++ b/log/base_handler.ts @@ -51,20 +51,14 @@ 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 f49d66463cda..a26270803d0a 100644 --- a/log/console_handler.ts +++ b/log/console_handler.ts @@ -25,17 +25,12 @@ 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: @@ -57,7 +52,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 ce02a2620e42..f265e13cd42e 100644 --- a/log/file_handler.ts +++ b/log/file_handler.ts @@ -85,13 +85,6 @@ 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 ba9c9c215d43..f661e3011124 100644 --- a/log/logger.ts +++ b/log/logger.ts @@ -121,9 +121,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, @@ -139,12 +139,6 @@ 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}"`; @@ -163,7 +157,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 186fd0c56200..5255951f60cb 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,12 +107,7 @@ 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();