rudionrails / yell

Yell - Your Extensible Logging Library
MIT License
311 stars 21 forks source link

Is there a way to fine tune the config to reduce noise during rspec testing? #16

Closed timuckun closed 11 years ago

timuckun commented 11 years ago

I have the following yell.yaml development: &development :level: 'gte.debug' :adapters:

test: *development

This works fine for me in development but I don't want a bunch of SQL spewing out during the tests. I do want to see the debug messages though.

I tried various tricks with setting the AR::Base.logger to nil but that doesn't seem to work because I think yell takes over. I also tried writing my own adapter which as a bunch of regex but that didn't work either (and was ugly to boot).

I looked at the event data being passed into the adapter and you can't tell if the source is Activerecord or not.

So how do I silence SQL statements in test mode without upping the level to info?

rudionrails commented 11 years ago

This is not a Yell-related question. As you already pointed out, it depends on ActiveRecord or Rspec. However, if you want to find out the caller of your logger, you can enable trace like so:

# config/yell.yml

development: &development
  :adapters:
    - :datefile:
      :keep: 7
      :trace: true # this enables tracing for all log levels and will make logging really slow
      :format: "%l [%F:&n] %d : %m" # with %F:%n you can print out the File and line of the logger's caller

P.S. You don't need to privide a level when you want to print from :debug severity and onwards. Also, you may leave the filename as Yell will attepmt to figure out your environment and use this as logfile.