Skip to content

Commit

Permalink
fix(shared/logger): log with correct line number in devtools (#546)
Browse files Browse the repository at this point in the history
  • Loading branch information
sidvishnoi authored Aug 29, 2024
1 parent da09be6 commit 89fe33f
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/shared/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@ export const createLogger = (level: log.LogLevelDesc = 'DEBUG') => {
const factory = log.methodFactory;
log.methodFactory = (methodName, logLevel, loggerName) => {
const raw = factory(methodName, logLevel, loggerName);

return function (...args) {
const messages = [
`%c${loggerName as string}`,
'font-weight: bold; text-transform: uppercase; background: #2f8785; padding-inline: 5px;',
...args,
];
raw(...messages);
};
return raw.bind(
log,
`%c${loggerName as string}`,
'font-weight: bold; text-transform: uppercase; background: #2f8785; color: #fff; padding-inline: 5px;',
);
};
log.rebuild();

Expand Down

0 comments on commit 89fe33f

Please sign in to comment.