i-break-codes / logerr

Make JavaScript errors readable, and log them remotely.
MIT License
398 stars 26 forks source link

Remove the listener #7

Closed shalomdotnet closed 8 years ago

shalomdotnet commented 8 years ago

Right now, you're not remove the event listener before re-initialize. So, if i wrote:

Error.init();
Error.init({ detailedErrors: false });

It's still write to console all the details.

Even worse, in case i want to remote-logging only piece of code, i write:

Error.init(
{
  remoteLogging: true,
  remoteSettings: {...}
});
// some code
Error.init({ remoteLogging: false });

If an error throw after this, two things happen:

i-break-codes commented 8 years ago

Can you send a PR which will be helpful for me to understand what you are trying to explain me here? It will surely attach an event but won't output any logs as I check the the config before throwing errors, but I would really appreciate if you have a better solution.

Thanks.

shalomdotnet commented 8 years ago

There were two problems in the orginal code:

  1. When calling init() again, a new listener created, but the old is still active.
  2. the old listener check his instance of config, so even if i change the config in the second call, it still check the first config.