Class: DohLogger::Event

Inherits:
Object show all
Defined in:
lib/doh/logger/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#exceptionObject

Returns the value of attribute exception.



8
9
10
# File 'lib/doh/logger/event.rb', line 8

def exception
  @exception
end

#locationObject

Returns the value of attribute location.



8
9
10
# File 'lib/doh/logger/event.rb', line 8

def location
  @location
end

#msgObject

Returns the value of attribute msg.



8
9
10
# File 'lib/doh/logger/event.rb', line 8

def msg
  @msg
end

#pidObject

Returns the value of attribute pid.



8
9
10
# File 'lib/doh/logger/event.rb', line 8

def pid
  @pid
end

#severityObject

Returns the value of attribute severity.



8
9
10
# File 'lib/doh/logger/event.rb', line 8

def severity
  @severity
end

#timeObject

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_stackObject



19
20
21
# File 'lib/doh/logger/event.rb', line 19

def call_stack
  @exception ? @exception.backtrace : caller
end

#inspectObject



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

#source_ipObject



23
24
25
# File 'lib/doh/logger/event.rb', line 23

def source_ip
  Doh::source_ip
end