Skip to content

Commit

Permalink
fix: fixes undefined this in logger methods
Browse files Browse the repository at this point in the history
  • Loading branch information
acaldas committed Aug 12, 2024
1 parent e72917d commit d5a8fac
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/services/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ import { ILogger, setLogger } from 'document-drive/logger';
class ConnectLogger implements ILogger {
#logger: ILogger = console;

constructor() {
// Bind all methods to the current instance
this.log = this.log.bind(this);
this.info = this.info.bind(this);
this.warn = this.warn.bind(this);
this.error = this.error.bind(this);
this.debug = this.debug.bind(this);
this.trace = this.trace.bind(this);
}

set logger(logger: ILogger) {
this.#logger = logger;
}
Expand Down

0 comments on commit d5a8fac

Please sign in to comment.