Argh, this still isn't quite there yet. Now I can't start my app with script/console, which is convenient sometimes. Because in script/console, somehow ActiveSupport hasn't yet been loaded when it loads the environment.
So I had to add a "require 'active_support'" to my environment, and now console is happy. I hope that won't mess up anything else in the Rails load order. I had no idea I'd have to get so much into the guts of Rails just to set a custom log format. Jonathan Rochkind wrote: > 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 rubyonrails-talk@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---