pimterry / loglevel

:ledger: Minimal lightweight logging for JavaScript, adding reliable log level methods to wrap any available console.log methods
MIT License
2.62k stars 157 forks source link

Adding a critical log level #108

Closed asasine closed 7 years ago

asasine commented 7 years ago

We use loglevel for a website at school and are big fans of its plugins, especially sending to a remote server. We are attempting to configure our logger to raise incident emails/texts/notifications whenever very serious problems occur. Since we use error logs often enough, can a critical level be added, one step above error?

pimterry commented 7 years ago

For historical reasons, I'm afraid that's more difficult than it sounds. Internally, levels are stored numerically, with 0 being trace, up to 4 being error, and 5 being silent. If you set a level, every numerically lower level is silenced.

critical would have to be the new 5, bumping silent to 6, and this is a breaking change, because:

This isn't a great design for extensibility in levels, which is part of why I've avoided doing it until now, and I'm going to have to say no to this I'm afraid.

There are a few easy workarounds though. The obvious ones that jump to mind:

Happy to chat about other solutions, but I think it's very unlikely I'm going to add this to the library, sorry.