Class: DohLogger::Event
Instance Attribute Summary collapse
-
#exception ⇒ Object
Returns the value of attribute exception.
-
#location ⇒ Object
Returns the value of attribute location.
-
#msg ⇒ Object
Returns the value of attribute msg.
-
#pid ⇒ Object
Returns the value of attribute pid.
-
#severity ⇒ Object
Returns the value of attribute severity.
-
#time ⇒ Object
Returns the value of attribute time.
Instance Method Summary collapse
- #call_stack ⇒ Object
-
#initialize(severity, msg, location = '', excpt = nil, literal = false) ⇒ Event
constructor
A new instance of Event.
- #inspect ⇒ Object
- #source_ip ⇒ Object
Constructor Details
#initialize(severity, msg, location = '', excpt = nil, literal = false) ⇒ Event
Returns a new instance of Event.
10 11 12 13 14 15 16 17 |
# File 'lib/doh/logger/event.rb', line 10 def initialize(severity, msg, location = '', excpt = nil, literal = false) msg = msg.gsub(/\n/, '\n').gsub(/\r/, '\r').gsub(/\t/, '\t') if !literal @severity = severity @msg = msg.firstn(4096) @location = location @exception = excpt @time = Time.now end |
Instance Attribute Details
#exception ⇒ Object
Returns the value of attribute exception.
8 9 10 |
# File 'lib/doh/logger/event.rb', line 8 def exception @exception end |
#location ⇒ Object
Returns the value of attribute location.
8 9 10 |
# File 'lib/doh/logger/event.rb', line 8 def location @location end |
#msg ⇒ Object
Returns the value of attribute msg.
8 9 10 |
# File 'lib/doh/logger/event.rb', line 8 def msg @msg end |
#pid ⇒ Object
Returns the value of attribute pid.
8 9 10 |
# File 'lib/doh/logger/event.rb', line 8 def pid @pid end |
#severity ⇒ Object
Returns the value of attribute severity.
8 9 10 |
# File 'lib/doh/logger/event.rb', line 8 def severity @severity end |
#time ⇒ Object
Returns the value of attribute time.
8 9 10 |
# File 'lib/doh/logger/event.rb', line 8 def time @time end |
Instance Method Details
#call_stack ⇒ Object
19 20 21 |
# File 'lib/doh/logger/event.rb', line 19 def call_stack @exception ? @exception.backtrace : caller end |
#inspect ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/doh/logger/event.rb', line 27 def inspect result = "{'severity' => #{@severity.inspect}, 'msg' => #{@msg.inspect}, 'location' => #{@location.inspect} 'exception' => #{@exception.inspect} 'time' => #{@time.inspect}}" if @exception result += ", backtrace: #{@exception.backtrace.inspect}" end result end |