2011/2/1 Albert Català <li...@ruby-forum.com>: > I whish configure logger, adding a prefix in all "logger.error(..)", a > prefix like "ERROR------------------>", to be able, then to search in > log file, easily.
> Could someone guide me for the right way? I'm absolutly lost. I don't know about the "right" way :-) but I wanted timestamps for one of my apps, so put this in my application_controller.rb : class ActiveSupport::BufferedLogger SEVERITIES = { 0 => 'DEBUG', 1 => 'INFO', 2 => 'WARN', 3 => 'ERROR', 4 => 'FATAL', 5 => 'UNKNOWN' } unless defined?(SEVERITIES) def add(severity, message = nil, progname = nil, &block) return if @level > severity message = (message || (block && block.call) || progname).to_s message = "#{Time.current.getlocal.strftime('%F-%H:%M:%S')} #{SEVERITIES[severity]} #{message}\n" unless message[-1] == ?\n buffer << message auto_flush message end end There certainly could be other ways, but this works. HTH! -- Hassan Schroeder ------------------------ hassan.schroe...@gmail.com twitter: @hassan -- 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 rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.