Skip to content

Commit

Permalink
fix: eslint errors with logger
Browse files Browse the repository at this point in the history
  • Loading branch information
cplee committed Oct 25, 2022
1 parent 11ca5f4 commit e1b3979
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
type LogAttributes = { [key: string]: string | boolean | Error | undefined };

export class Logger {
persistentAttributes = {};
persistentAttributes: LogAttributes = {};

info(message: string, ...attributes: LogAttributes[]) {
info(message: string, ...attributes: LogAttributes[]): void {
process.stdout.write(this.formatMessage(message, {level: 'INFO'}, ...attributes)+'\n');
//console.log(this.formatMessage(message, {level: 'INFO'}, ...attributes));
}
warn(message: string, ...attributes: LogAttributes[]) {
warn(message: string, ...attributes: LogAttributes[]): void {
process.stdout.write(this.formatMessage(message, {level: 'WARN'}, ...attributes)+'\n');
//console.log(this.formatMessage(message, {level: 'WARN'}, ...attributes));
}
error(message: string, ...attributes: LogAttributes[]) {
error(message: string, ...attributes: LogAttributes[]): void {
process.stdout.write(this.formatMessage(message, {level: 'ERROR'}, ...attributes)+'\n');
//console.log(this.formatMessage(message, {level: 'ERROR'}, ...attributes));
}
appendKeys(attributes: LogAttributes) {
appendKeys(attributes: LogAttributes): void {
this.persistentAttributes = {...this.persistentAttributes, ...attributes};
}
formatMessage(message: string, ...attributes: LogAttributes[]) {
formatMessage(message: string, ...attributes: LogAttributes[]): string {
const formattedMessage = [this.persistentAttributes, ...attributes].reduce((combined: LogAttributes, current: LogAttributes) => {
return {...combined, ...current};
}, {message});
Expand Down

0 comments on commit e1b3979

Please sign in to comment.