Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(log): Revert "deprecate(log): deprecate internal utility methods" (#4436) #4572

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading