Class: Logfoo::ExceptionEntry

Inherits:
Struct
  • Object
show all
Defined in:
lib/logfoo/entry.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#exceptionObject

Returns the value of attribute exception



17
18
19
# File 'lib/logfoo/entry.rb', line 17

def exception
  @exception
end

#levelObject

Returns the value of attribute level



17
18
19
# File 'lib/logfoo/entry.rb', line 17

def level
  @level
end

#payloadObject

Returns the value of attribute payload



17
18
19
# File 'lib/logfoo/entry.rb', line 17

def payload
  @payload
end

#scopeObject

Returns the value of attribute scope



17
18
19
# File 'lib/logfoo/entry.rb', line 17

def scope
  @scope
end

#threadObject

Returns the value of attribute thread



17
18
19
# File 'lib/logfoo/entry.rb', line 17

def thread
  @thread
end

#timeObject

Returns the value of attribute time



17
18
19
# File 'lib/logfoo/entry.rb', line 17

def time
  @time
end

Class Method Details

.build(scope, ex, payload = nil, options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/logfoo/entry.rb', line 19

def build(scope, ex, payload = nil, options = {})
  self.new(
    options[:level],
    Time.now,
    scope,
    ex,
    payload,
    Thread.current.object_id
  )
end

Instance Method Details

#to_hObject



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/logfoo/entry.rb', line 31

def to_h
  {
    level:     level || :error,
    time:      time  || Time.now,
    msg:       exception.message,
    scope:     scope,
    err:       exception.class.to_s,
  }.merge!(
    payload || {}
  ).merge!(
    thread:  thread
  )
end