xpl / ololog

A better console.log for the log-driven debugging junkies
https://www.npmjs.com/package/ololog
The Unlicense
215 stars 8 forks source link

suggestion: local storage enable/disable #22

Open cmonacaps opened 3 years ago

cmonacaps commented 3 years ago

I like ololog a lot better than debug.

But one feature we use organizationally with debug is the local storage enablement.

Screen Shot 2020-09-10 at 4 24 33 PM

It may already be familiar to anyone reading this. But in case not, the way it works is with local storage debug missing or empty, all debug() output is disabled. If its value is *, all debug() output is enabled. Finally it can be set to a comma-separated list of context names, which correlate with require('debug')('context:name')('hello world').

This seems like 2 features unavailable with ololog - 1) local storage enablement and 2) named logging contexts.

If either or both of these features are actually available please just let me know. I'm not perfectly aware of everything ololog can do.

But the local storage enablement alone prevents me from using ololog in our frontend (react) apps.

Because I have a choice, I think, I can enable it or disable it in the build by using ololog.noop when NODE_ENV==='production' and configuring it as wanted otherwise. Or I can leave it enabled.

In the first case, if there's a problem in production, people will be upset we can't see the logging. In the second, the app will seem spammy, people here would prefer to not have logging output by default from our code.

If it seems like it might be possible to add one or both of these features I'd be willing to try to submit a PR according to whatever constraints you might have for it.