Skip to content

Commit 7380665

Browse files
committed
Notify log subscription only when logger exists
Move logSubscription.notify into the branch that calls this.logger.log and remove the previous external call. This ensures the subscription is notified only when the configured logger is used, avoiding redundant or spurious notifications.
1 parent 2c57faf commit 7380665

File tree

1 file changed

+1
-1
lines changed
  • packages/napcat-core/helper

1 file changed

+1
-1
lines changed

packages/napcat-core/helper/log.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ export class LogWrapper implements ILogWrapper {
196196
// eslint-disable-next-line no-control-regex
197197
this.logger.log(level, message.replace(/\x1B[@-_][0-?]*[ -/]*[@-~]/g, ''));
198198
}
199+
logSubscription.notify(JSON.stringify({ level, message }));
199200
}
200-
logSubscription.notify(JSON.stringify({ level, message }));
201201
}
202202

203203
log (...args: any[]) {

0 commit comments

Comments
 (0)