Class: DohLog::Event
Instance Attribute Summary collapse
-
#exception ⇒ Object
Returns the value of attribute exception.
-
#extras ⇒ Object
Returns the value of attribute extras.
-
#location ⇒ Object
Returns the value of attribute location.
-
#msg ⇒ Object
Returns the value of attribute msg.
-
#severity ⇒ Object
Returns the value of attribute severity.
-
#time ⇒ Object
Returns the value of attribute time.
Instance Method Summary collapse
- #call_stack ⇒ Object
- #datetime_text ⇒ Object
- #exception_text ⇒ Object
-
#initialize(severity, msg, location = '', exception = nil) ⇒ Event
constructor
A new instance of Event.
- #severity_text ⇒ Object
- #summary ⇒ Object
- #time_text ⇒ Object
Constructor Details
#initialize(severity, msg, location = '', exception = nil) ⇒ Event
Returns a new instance of Event.
8 9 10 11 12 |
# File 'lib/dohlog/event.rb', line 8 def initialize(severity, msg, location = '', exception = nil) @severity, @msg, @location, @exception = severity, msg, location, exception @extras = {} @time = Time.now end |
Instance Attribute Details
#exception ⇒ Object
Returns the value of attribute exception.
6 7 8 |
# File 'lib/dohlog/event.rb', line 6 def exception @exception end |
#extras ⇒ Object
Returns the value of attribute extras.
6 7 8 |
# File 'lib/dohlog/event.rb', line 6 def extras @extras end |
#location ⇒ Object
Returns the value of attribute location.
6 7 8 |
# File 'lib/dohlog/event.rb', line 6 def location @location end |
#msg ⇒ Object
Returns the value of attribute msg.
6 7 8 |
# File 'lib/dohlog/event.rb', line 6 def msg @msg end |
#severity ⇒ Object
Returns the value of attribute severity.
6 7 8 |
# File 'lib/dohlog/event.rb', line 6 def severity @severity end |
#time ⇒ Object
Returns the value of attribute time.
6 7 8 |
# File 'lib/dohlog/event.rb', line 6 def time @time end |
Instance Method Details
#call_stack ⇒ Object
36 37 38 |
# File 'lib/dohlog/event.rb', line 36 def call_stack if @exception then @exception.backtrace else caller end end |
#datetime_text ⇒ Object
22 23 24 |
# File 'lib/dohlog/event.rb', line 22 def datetime_text @time.strftime("%Y-%m-%d %H:%M:%S.") << "%03d" % (@time.usec / 1000) end |
#exception_text ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/dohlog/event.rb', line 26 def exception_text return '' unless @exception if @exception.backtrace stack = @exception.backtrace.collect { |elem| "=> #{elem}" }.join("\n") else stack = 'no backtrace available...?' end "=> exception: #{@exception.class} - #{@exception.}\n=> stack:\n#{stack}" end |
#severity_text ⇒ Object
14 15 16 |
# File 'lib/dohlog/event.rb', line 14 def severity_text DohLog::severity_text(@severity) end |
#summary ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/dohlog/event.rb', line 40 def summary if @extras.empty? extra_str = '' else extra_ary = [] @extras.each_pair do |key, value| extra_ary << "#{key}: #{value}" end extra_str = "<#{extra_ary.join(', ')}> " end threadstr = ":#{Thread.current.object_id}" if DohLog.should_log_thread_ids "#{datetime_text} <#{Process.pid}#{threadstr}> [#{severity_text}] (#{location}) #{extra_str}: #{msg}" end |
#time_text ⇒ Object
18 19 20 |
# File 'lib/dohlog/event.rb', line 18 def time_text @time.strftime("%H:%M:%S.") << "%03d" % (@time.usec / 1000) end |