Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable control of the log level via environment variables #494

Closed
gajus opened this issue Apr 17, 2017 · 2 comments
Closed

Enable control of the log level via environment variables #494

gajus opened this issue Apr 17, 2017 · 2 comments

Comments

@gajus
Copy link

gajus commented Apr 17, 2017

It would be useful to be enable control-override of the createLogger level option.

This setting ought to be controlled using environment variables, e.g. BUNYAN_LOG_LEVEL. This way it would be possible to enable different log levels without tracing down every instance of createLogger or leaving it up to the developer to respect the suggested BUNYAN_LOG_LEVEL setting.

@trentm
Copy link
Owner

trentm commented Apr 17, 2017

See #176 for a similar issue. IMO control of logging output streams and levels belongs in the application using Bunyan, and not in the library itself. In #176 I created an example file that shows how the app using Bunyan can control this with environment variables itself: https://github.com/trentm/node-bunyan/blob/master/examples/mute-by-envvars-stream.js

Similar could be done for the log level. Something like:

var level = process.env.BUNYAN_LOG_LEVEL || 'info';
var log = bunyan.createLogger({name: 'foo', level: level});

@gajus
Copy link
Author

gajus commented Apr 17, 2017

The problem with:

var level = process.env.BUNYAN_LOG_LEVEL || 'info';
var log = bunyan.createLogger({name: 'foo', level: level});

is that you then leave it up to the developers to enforce a consistent standard. Which is fine. On the other hand, modules such as debug focus on standardising conventions, which ... at the level of debugging libraries, has been tremendously useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants