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

Ability to set level only if one is not persisted #74

Closed Mr0grog closed 9 years ago

Mr0grog commented 9 years ago

In environments where a logging level has been explicitly set and persisted (usually a developer’s browser), it’d be nice to be able to leave the logging level alone, while otherwise giving a default logging level to use if one hasn’t been persisted. The only way to accomplish this right now is to explicitly peek into local storage or cookies to see if a value is set, which isn’t very nice.

I’m thinking this could either be a third argument to setLevel or, probably clearer, a separate method, e.g. setDefaultLevel.

Mr0grog commented 9 years ago

I'm happy to do a PR for this if you'd like, too.