davetron5000 / optparse-plus

Start your command line scripts off right in Ruby
http://davetron5000.github.com/optparse-plus
Apache License 2.0
521 stars 54 forks source link

How do I get at the log-level? #94

Closed blysik closed 9 years ago

blysik commented 9 years ago

I want to key an if statement off of --log-level debug being set.

I can't quite figure out what my code should be looking at.

If I use @@logger.level == 0, it works when debug is set. But if I don't set debug, it complains @@logger.level doesn't exist.

davetron5000 commented 9 years ago

If you are using use_log_level_option, you should be able to get the log level via logger.level.

This assumes you have mixed-in CLILogging.

@@logger isn't set by methadone, so I'm not sure why it ever works for you

davetron5000 commented 9 years ago

Re-open if you weren't able to get what you needed from logger.level

blysik commented 9 years ago

Sorry, forgot to update this. It works great. Simply doing:

if logger.level == 0
  faraday.response :logger
end

So I get more debugging out of faraday, if I set debug in methadone. Thanks again.