Hi I would like to know how I can customize logger message format in rails 2.3.5 Thanks in advance Tom -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
You can overload call method from Formatter. example: class Logger class Formatter Format = "%s [%s] %s %sn" def call(severity, time, progname, msg) Format % [severity, format_datetime(time), progname, msg] end end end $LOG.error(''This is much shorter.'') # ERROR [2006-03-31T19:35:01.058646 ] This is much shorter. 2010/3/22 Tom Mac <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>:> Hi > I would like to know how I can customize logger message format in > rails 2.3.5 > > Thanks in advance > Tom > -- > Posted via http://www.ruby-forum.com/. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 22 March 2010 11:40, Tom Mac <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi > I would like to know how I can customize logger message format in > rails 2.3.5I am not sure exactly what you are asking, but the rails guide on Testing at http://guides.rubyonrails.org/ has some information on how to use the logger. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi> You can overload call method from Formatter. > > example: > > class Logger > class Formatter > Format = "%s [%s] %s %sn" > def call(severity, time, progname, msg) > Format % [severity, format_datetime(time), progname, msg] > end > end > end > > $LOG.error(''This is much shorter.'') > # ERROR [2006-03-31T19:35:01.058646 ] This is much shorter. >Thanks for your reply. Where should I place this code? In environment.rb or any initializer? Thanks Tom -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.