I needed to blot out hugh binary data in the log so here's what I use
in 2.1. I have a hard time believing that there's not a simpler way to
blot out huge binary data but I've been unable to find it. I recall
trying to use filter_parameter_logging from the controllers, but it
didn't work for me at the time (likely my issue, not Rails). Anyhow
this code shows one way to muck with the logger, maybe it'll help.
It's in my environment.rb. Bananas not included.

module ActiveSupport
  class BufferedLogger
    def add(severity, message = nil, progname = nil, &block)
      return if @level > severity
      message = (message || (block && block.call) || progname).to_s
      message.to_str.gsub!(/(\s|\()x'([0-9a-fA-F]*)'(,|\s|\))/,'\1x
\'BINARY_DATA\'\3')

      level = {
        0 => "D",
        1 => "I",
        2 => "W",
        3 => "E",
        4 => "F"
      }[severity] || "U"

      message = "[%s: %s #%d] %s" % [level,
                                     Time.now.strftime("%m%d %H:%M:
%S"),
                                     $$,
                                     message]


      message = "#{message}\n" unless message[-1] == ?\n
      buffer << message
      auto_flush
      message
    end
  end
end


--~--~---------~--~----~------------~-------~--~----~
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