TwP / logging-rails

Railtie for integrating the Logging framework with Rails
81 stars 27 forks source link

log statements printed to STDOUT on rake:test #6

Closed dvgica closed 12 years ago

dvgica commented 12 years ago

This is a great gem, I really like it so far. However I'm seeing one small issue, and I'm not sure if the problem is my config or not.

When I run rake:test, log statements from the DB preparation get dumped to STDOUT. I have tried setting options in config/environments/test.rb, but this doesn't seem to make a difference:

# Set the logging destination(s)
config.log_to = %w[]

Here's a (partial) sample run:

davidv@davidv /media/Files/projects/LMS/src/web/trunk $ rake test
[2012-04-10 14:33:00] INFO  Rails : New Relic Agent not running.
[2012-04-10 14:33:01] DEBUG ActiveRecord::Base :   SQL (0.4ms)  SHOW TABLES
[2012-04-10 14:33:01] DEBUG ActiveRecord::Base :   SQL (0.3ms)  SHOW TABLES
[2012-04-10 14:33:01] DEBUG ActiveRecord::Base :   SQL (0.3ms)  SELECT `schema_migrations`.`version` FROM `schema_migrations`
[2012-04-10 14:33:01] DEBUG ActiveRecord::Base :   SQL (0.4ms)  SHOW FULL TABLES WHERE Table_type = 'BASE TABLE'
[2012-04-10 14:33:01] DEBUG ActiveRecord::Base :   SQL (0.3ms)  SHOW CREATE TABLE `authorization_events`
...

This continues, printing out all the SQL to create the DB. Then the test output prints as normal.

I'm running Rails 3.0.12, Ruby 1.9.3p125, logging-rails 0.4.0, and logging 1.7.2. Running on Linux Mint 9.

Any ideas? Thanks!

TwP commented 12 years ago

You are not specifying your RACK_ENV on the command line. The environment being loaded is the default :development environment. What you really want is:

RACK_ENV=test rake test

There is also a new option to disable the configuration dump from the Logging framework. In your config/environments/test.rb file you should add the following:

# Show the logging configuration on STDOUT
config.show_log_configuration = false
dvgica commented 12 years ago

Right you are, thanks!