What's New in Edge Rails: Logging Gets a Little Snappier

Posted by ryan
at 7:55 AM on Tuesday, September 25, 2007



Edge Rails just got a new, buffered logger that will, apparently, make logging in Rails a little snappier.

This new logger is now the default, though you can change it back to the original logger in your environment.rb with:


config.logger = Logger.new('/path/to/log', Logger::DEBUG)

Though I’m not sure why you’d want to do that…

tags: ruby, rubyonrails

Comments

Leave a response

  1. Manfred StienstraSeptember 25, 2007 @ 08:13 AM

    You want to use the old logger because the BufferedLogger and the config.logger override seem to be broken at the moment. You can fix it by specifying:

    RAILS_DEFAULT_LOGGER = Logger.new(File.join(RAILS_ROOT, ‘log’, ”#{RAILS_ENV}.log”))

  2. IanSeptember 25, 2007 @ 08:59 AM

    Highly recommend sticking with the old Logger until submitted patches have been incorporated as this latest change by DHH breaks partial rendering (due to a benchmarking routine that calls logger.add(), a method missing from his new implementation). How that wasn’t discovered before he committed the changes I do not know.

  3. Manfred StienstraSeptember 25, 2007 @ 09:35 AM

    You don’t see the logger problems with partials in tests because tests don’t use the BufferedLogger but either a mock, stub or default Ruby logger.

    Obviously they didn’t run an application on this source before committing it, which is understandable.

  4. Luke RedpathSeptember 25, 2007 @ 10:11 AM

    Manfred – whilst I agree that unit tests wouldn’t pick this kind of thing up if the tests were (correctly) using a mocked or stubbed logger object, it only highlights the importance of having a good suite of functional/acceptance tests that will catch this sort of thing.

  5. DHHSeptember 25, 2007 @ 12:47 PM

    This was fixed and works now. That’s what you get for checking in late at night ;)