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

Send Logger.Level.ERROR logs to STDERR #40

Merged
merged 1 commit into from
Aug 13, 2023
Merged
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
14 changes: 11 additions & 3 deletions src/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@ class Logger {
}

/**
* Print object without any log level
* Print object without any log level to STDOUT
* @param obj Object to print
*/
private send(...obj: any[]): void {
private stdout(...obj: any[]): void {
console.log(...obj);
}

/**
* Print object without any log level to STDERR
* @param obj Object to print
*/
private stderr(...obj: any[]): void {
console.error(...obj);
}

/**
* Format string with log level and prefix
* @param level Log level
Expand All @@ -29,7 +37,7 @@ class Logger {
* @param [obj] Objects to print
*/
public log(level: Logger.Level, message: string, ...obj: any[]): void {
this.send(this.format(level, message), ...obj);
this[level === Logger.Level.ERROR ? "stderr" : "stdout"](this.format(level, message), ...obj);
}

/**
Expand Down
Loading