dbfannin / ngx-logger

Angular logger
MIT License
428 stars 110 forks source link

Subscribe to Logger Methods #310

Open maks-humeniuk opened 2 years ago

maks-humeniuk commented 2 years ago

I have some cases in my app, where I need to do something like this:

this.logger.info('Redirecting to remote...');
location.href = 'https://path/to/remote';

Obviously, log request is getting canceled, because calling document is destroyed before it completes.

So, it'd be great to be able to subscribe to logger methods like this:

this.logger.info('Redirecting to remote...').subscribe((): void => {
  location.href = 'https://path/to/remote';
});

or

this.logger.info('Redirecting to remote...').then((): void => {
  location.href = 'https://path/to/remote';
});
bmtheo commented 2 years ago

Yes indeed

This would require some thinking whether we include the API request in this or not

maks-humeniuk commented 2 months ago

Hi. Did you find this reasonable to add to the library? My log requests are still not sent due to redirects 😅.