kutuluk / loglevel-plugin-remote

A loglevel plugin for sending browser logs to a server
MIT License
102 stars 36 forks source link

Logs from not-root loggers created before applying plugin are not being sent #44

Open sergeyphi opened 1 year ago

sergeyphi commented 1 year ago

In my case, I create loggers for each module on init. Then as soon as remote logging endpoint auth is available I apply remote plugin. But the logs from loggers created before that moment are not being sent:

log.enableAll();
const loggerTwo = log.getLogger('module-two');
// ...

// auth is available, applying remote plugin:
remote.apply(log, options);

log.debug('this message will be sent to remote`);
loggerTwo.debug('this message will NOT be sent to remote`);

And there is no way to apply remote plugin to module-two logger separately:

remote.apply(log.getLogger('module-two'), options); // will fail

Since .apply() is expecting root logger and will throw: Argument is not a root loglevel object error.

Any help is appreciated!