Thursday, August 16, 2007

Customize Logger message format

I Hate these long, frustrating long messages coming out on me when i look at the log. They are long, and needed a refreshing change for my opinion.

here is what i found:
There is a method which is responsible for the actual STDOUT printing for the log file, it's called Logger#format_message. I decided to overrun it in a more pretty way.

I created a /lib library called logger_format.rb and required it in environment.rb,
  1. class Logger
  2. def format_message(level, time, progname, msg)
  3. "#{time.to_s(:long)} -- #{msg}\n"
  4. end
  5. end
for example.
try it out and feel free to modify the output structure at will.


No comments:

Post a Comment

Tell me what you think