Skip to content

Commit

Permalink
fix(log): Revert "deprecate(log): deprecate internal utility methods" (
Browse files Browse the repository at this point in the history
  • Loading branch information
kt3k committed Apr 11, 2024
1 parent 6220121 commit 0c58441
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 38 deletions.
8 changes: 1 addition & 7 deletions log/base_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

Expand Down
11 changes: 3 additions & 8 deletions log/console_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -57,7 +52,7 @@ export class ConsoleHandler extends BaseHandler {
return msg;
}

override #log(msg: string) {
override log(msg: string) {
console.log(msg);
}
}
7 changes: 0 additions & 7 deletions log/file_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 3 additions & 9 deletions log/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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}"`;
Expand All @@ -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(",")
}}`;
}
Expand Down
9 changes: 2 additions & 7 deletions log/rotating_file_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,15 @@ 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;
}

super.log(msg);

this.#currentFileSize += msgByteLength;
}
#rotateLogFiles() {
this.rotateLogFiles();
}
/**
* @deprecated (will be removed in 0.220.0)
*/

rotateLogFiles() {
this.flush();
this._file!.close();
Expand Down

0 comments on commit 0c58441

Please sign in to comment.