Simple Logging Customization

Is there a simple way to customize logging so that when you call the
logger method it includes the severity in the log? I just want to
make it easy to find with something like a GREP.

So a call to this:
logger.warn(‘my message’)

Would put this in the log:
WARNING: My message

Thanks,
Tom

On Mon, Apr 14, 2008 at 5:09 PM, TomRossi7 [email protected] wrote:

Is there a simple way to customize logging so that when you call the
logger method it includes the severity in the log? I just want to
make it easy to find with something like a GREP.

So a call to this:
logger.warn(‘my message’)

Would put this in the log:
WARNING: My message

http://wiki.rubyonrails.org/rails/pages/HowtoConfigureLogging

Just create a custom formatter and reference the log level there.
Something like the following, warning this has not been tested.

class Logger
def format_message(severity, timestamp, progname, msg)
“#{RAILS_DEFAULT_LOGGER.level} #{timestamp} (#{$$}) #{msg}\n”
end
end

Regards,
Michael G.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs