On Mon, Mar 14, 2016 at 10:10 AM, sebb <[email protected]> wrote: > On 14 March 2016 at 12:55, sebb <[email protected]> wrote: >> It would be useful to be able to initialise the default log level but >> still allow CLI over-ride. >> >> I've found a hacky fix: >> >> Wunderbar.log_level = 'info' unless Wunderbar.log_level == 'debug' # >> don't override command-line level >> >> however that relies on knowing that debug (and only debug) is more >> verbose than info. > > I can improve that with: > > Wunderbar.log_level = 'info' unless Wunderbar.logger.info? > > however this still overrides a CLI arg of --warn etc. > > I tried another hack: > > ARGV.unshift '--info' > > at the start of the script, but that does not work properly because > Wunderbar does not process ARGV in order. > But even if it did, updating the args would be a hack. > > So I think there needs to be a way to override the default level.
I just pushed out a change to wunderbar that adds that: https://github.com/rubys/wunderbar/commit/3e9472f811b616c190bc94d23606c4864ee104cc > It would also be useful to be able to override the default output > stream; $stderr is not always suitable. If you need more interfaces, they can be added to wunderbar. Also, you can create your own logger: http://ruby-doc.org/stdlib-2.3.0/libdoc/logger/rdoc/Logger.html You can even make wunderbar use that logger: Wunderbar.logger = your_custom_logger >> Also modifying the formatter message is a bit messy; it would be >> useful if this could be specified when creating the logger. >> >> I don't know how to do this in Ruby - if it's even possible? - Sam Ruby
