TomFrost / Bristol

Insanely configurable logging for Node.js
MIT License
113 stars 19 forks source link

Change log level in runtime #37

Open mostr opened 7 years ago

mostr commented 7 years ago

Say I have app running with configuration like this:

bristol.addTarget('console').withLowestSeverity('info').withFormatter('human')

and would like to make logging more verbose by switching to debug without restarting an app (e.g. I'm having issues and would like to track them down with more logs).

I don't see a way to get this working, is this possible?

pixelprodev commented 7 years ago

@mostr You could create a separate logger and put it behind a flag. When you want to enable more verbose logging, flip the flag and it can start logging at your desired level. https://github.com/TomFrost/Bristol#more-than-one-logger

Considering the criteria of "not having to restart the app" its the only thing I can think of.

TomFrost commented 7 years ago

This is a great request, and I think it'll be pretty easy to address. For the 1.0 release, I've been considering adding a way to pull an array of the current targets, with the primary use case being after-the-fact advanced configuration for targets that were created through environment variables (see #31). With this feature, you could easily update the minimum log level and not have to worry about conditionals around your logging in the code.

Does that sound like it would cover your use case?