Closed asasine closed 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:
getLevel()
, and people might well depend on 5
meaning 'logging is disabled'setLevel(n)
, and people will very possibly expect setLevel(5)
to disable loggingThis 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:
error
for this.{ shouldLog: true }
), and either detect that in your log output, or add a loglevel plugin that spots this case client-side and handles it differently.Happy to chat about other solutions, but I think it's very unlikely I'm going to add this to the library, sorry.
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?