Skip to content

Commit

Permalink
fix: wrokaround logger self binding
Browse files Browse the repository at this point in the history
  • Loading branch information
fengkx committed Apr 10, 2022
1 parent e2b42f2 commit 86a74b3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion source/utils/logger.ts
Expand Up @@ -54,4 +54,13 @@ export function logDBError(error: any): void {
}
logger.error({ type: 'db', error });
}
export default logger;

const LEVELS = new Set<string | symbol>(Object.keys(logger.levels));
export default new Proxy(logger, {
get: (target, p) => {
if (LEVELS.has(p)) {
return target[p].bind(logger);
}
return target[p];
}
});

0 comments on commit 86a74b3

Please sign in to comment.