mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
removed default Formatter in logger, not needed with 1.8.7 upwards
Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
committed by
José Valim
parent
dad71c6099
commit
fd03f1738e
@@ -72,44 +72,6 @@ class Logger
|
||||
@formatter ||= SimpleFormatter.new
|
||||
end
|
||||
|
||||
unless const_defined? :Formatter
|
||||
class Formatter
|
||||
Format = "%s, [%s#%d] %5s -- %s: %s\n"
|
||||
|
||||
attr_accessor :datetime_format
|
||||
|
||||
def initialize
|
||||
@datetime_format = nil
|
||||
end
|
||||
|
||||
def call(severity, time, progname, msg)
|
||||
Format % [severity[0..0], format_datetime(time), $$, severity, progname,
|
||||
msg2str(msg)]
|
||||
end
|
||||
|
||||
private
|
||||
def format_datetime(time)
|
||||
if @datetime_format.nil?
|
||||
time.strftime("%Y-%m-%dT%H:%M:%S.") << "%06d " % time.usec
|
||||
else
|
||||
time.strftime(@datetime_format)
|
||||
end
|
||||
end
|
||||
|
||||
def msg2str(msg)
|
||||
case msg
|
||||
when ::String
|
||||
msg
|
||||
when ::Exception
|
||||
"#{ msg.message } (#{ msg.class })\n" <<
|
||||
(msg.backtrace || []).join("\n")
|
||||
else
|
||||
msg.inspect
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Simple formatter which only displays the message.
|
||||
class SimpleFormatter < Logger::Formatter
|
||||
# This method is invoked when a log event occurs
|
||||
|
||||
Reference in New Issue
Block a user