Okay, I finally figured out how to get this to work. Leave this here for 
future list archive searchers, since I had to put together a bunch of 
pieces.

My custom logger, based on this patch:
http://rails.lighthouseapp.com/projects/8994/tickets/1307-bufferedlogger-should-support-message-formatting

is in my lib/umlaut_logger.rb. So now that custom logger can take a 
formatter, like standard ruby Logger can.

For some reason, inside the environmental config block, auto-loading 
from constants doesn't seem to work yet, I needed to require_dependency 
it automatically.  Then, I really wanted to take the existing log and 
severity level fields from RAILS_DEFAULT_LOGGER, but 
RAILS_DEFAULT_LOGGER isn't set yet here. But if I wait until it IS set, 
then it's too late for re-setting it to easily have an effect. So I had 
to reconstruct what it did from source, and other people's suggetsions 
in the listserv archives.

So, in the config block:

    require_dependency 'umlaut_logger'
    severity_level = 
ActiveSupport::BufferedLogger.const_get(config.log_level.to_s.upcase)
    log_file = File.join(RAILS_ROOT, "log", "#{RAILS_ENV}.log")

    our_logger = UmlautLogger.new(log_file, severity_level)
    # eg, my real one is more complicated:
    our_logger.formatter = lambda {|severity_label, message| 
"#{severity_label}: #{message}"}

    config.logger = our_logger


That was kind of a lot of work to get custom formatting.  Phew.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to