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

Log level coupling to $VERBOSE and $DEBUG not always helpful #16

Open
tadman opened this issue Jan 29, 2021 · 2 comments
Open

Log level coupling to $VERBOSE and $DEBUG not always helpful #16

tadman opened this issue Jan 29, 2021 · 2 comments

Comments

@tadman
Copy link

tadman commented Jan 29, 2021

Anyone who uses libraries that generate a lot of warnings will resort to using -W0 as a default in Ruby. This does silence the warnings, but it also has the unfortunate side-effect of pretty much silencing Console.logger as well since the default level now moves up a notch.

What's doubly frustrating is anyone with the -W0 default will not see output from Console examples, where this:

require 'console'

Console.logger.info("Hello World")

Does nothing at all. This can be reproduced with RUBYOPT=-W0 ruby example.rb

Overriding this within an application is not convenient. Right now what I've found you have to do is:

ENV['CONSOLE_LEVEL'] ||= 'info'

Where that's a really round-about way of setting a default. It would be more convenient if the default_log_level could be specified, as in Console::Logger.default_log_level = :debug or whatever setting is desired, where that will be applied to all loggers created after that point.

@ioquatix
Copy link
Member

I agree with you, but I'm also not sure what the solution is.

Basically... log data should always be some kind of non-essential "debug output".

I wanted to try and make it tie into existing Ruby constructs for controlling log level.

@tadman
Copy link
Author

tadman commented May 1, 2021

There's nothing wrong with having defaults tied to Ruby's global verbosity level, but right now it's really awkward to try and separate those two to override it.

Most other logging tools, even Logger, support an arbitrary per-logger logging level override. Logger.new(level: :debug) for example.

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

No branches or pull requests

2 participants