Class: SemanticLogger::Appender::Base
- Defined in:
- lib/semantic_logger/appender/base.rb
Instance Attribute Summary collapse
-
#formatter ⇒ Object
Returns the value of attribute formatter.
Attributes inherited from Base
Instance Method Summary collapse
-
#default_formatter ⇒ Object
Default log formatter Replace this formatter by supplying a Block to the initializer Generates logs of the form: 2011-07-19 14:36:15.660 D [1149:ScriptThreadProcess] Rails – Hello World.
Methods inherited from Base
default_level, default_level=, #payload, #tags, #with_payload, #with_tags
Instance Attribute Details
#formatter ⇒ Object
Returns the value of attribute formatter.
12 13 14 |
# File 'lib/semantic_logger/appender/base.rb', line 12 def formatter @formatter end |
Instance Method Details
#default_formatter ⇒ Object
Default log formatter
Replace this formatter by supplying a Block to the initializer
Generates logs of the form:
2011-07-19 14:36:15.660 D [1149:ScriptThreadProcess] Rails -- Hello World
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/semantic_logger/appender/base.rb', line 18 def default_formatter Proc.new do |log| = log..collect { |tag| "[#{tag}]" }.join(" ") + " " if log. && (log..size > 0) = log..to_s << " -- " << log.payload.inspect if log.payload << " -- " << "#{log.exception.class}: #{log.exception.}\n#{(log.exception.backtrace || []).join("\n")}" if log.exception duration_str = log.duration ? "(#{'%.1f' % log.duration}ms) " : '' "#{SemanticLogger::Appender::Base.formatted_time(log.time)} #{log.level.to_s[0..0].upcase} [#{$$}:#{log.thread_name}] #{}#{duration_str}#{log.name} -- #{}" end end |