BACKTRACE

(condense)

Back to Posts List

GET

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,

<span class="keywords"><div id="hlDiv" class="dp-highlighter"><div class="bar"></div><ol class="dp-rb" start="1"><li class="alt"><span><span class="keyword">class</span><span> Logger  </span></span></li><li class=""><span>  <span class="keyword">def</span><span> format_message(level, time, progname, msg)  </span></span></li><li class="alt"><span>    <span class="string">"#{time.to_s(:long)} -- #{msg}\n"</span><span>  </span></span></li><li class=""><span>  <span class="keyword">end</span><span>    </span></span></li><li class="alt"><span><span class="keyword">end</span><span>  </span></span></li></ol></div></span><span class="keywords"></span>
for example.
try it out and feel free to modify the output structure at will.


POST

blog comments powered by Disqus

I Don't have cookies.

ELAD ENV

Variable Value
LINKEDIN
TWITTER
FACEBOOK
GITHUB
WWR
IRC
{ 'irc.freenode.net' => [ '#rubyonrails', '#railsbridge', '#ruby', '#mootools' ]}
SKYPE
eladmeidar

You're seeing this error because I think it is funny.