Class: Logfoo::ErrLine

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#exceptionObject

Returns the value of attribute exception

Returns:

  • (Object)

    the current value of exception



30
31
32
# File 'lib/logfoo/entries.rb', line 30

def exception
  @exception
end

#levelObject

Returns the value of attribute level

Returns:

  • (Object)

    the current value of level



30
31
32
# File 'lib/logfoo/entries.rb', line 30

def level
  @level
end

#logger_nameObject

Returns the value of attribute logger_name

Returns:

  • (Object)

    the current value of logger_name



30
31
32
# File 'lib/logfoo/entries.rb', line 30

def logger_name
  @logger_name
end

#payloadObject

Returns the value of attribute payload

Returns:

  • (Object)

    the current value of payload



30
31
32
# File 'lib/logfoo/entries.rb', line 30

def payload
  @payload
end

#threadObject

Returns the value of attribute thread

Returns:

  • (Object)

    the current value of thread



30
31
32
# File 'lib/logfoo/entries.rb', line 30

def thread
  @thread
end

#timeObject

Returns the value of attribute time

Returns:

  • (Object)

    the current value of time



30
31
32
# File 'lib/logfoo/entries.rb', line 30

def time
  @time
end

Class Method Details

.build(logger_name:, exception:, payload: nil, level: nil) ⇒ Object



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

def build(logger_name:, exception:, payload: nil, level: nil)
  self.new(
    level || :error,
    Time.now.utc,
    logger_name,
    exception,
    payload || {},
    Thread.current.object_id
  )
end

Instance Method Details

#to_hObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/logfoo/entries.rb', line 44

def to_h
  {
    level:  level,
    time:   time,
    msg:    exception.message,
    logger: logger_name,
    err:    exception.class.to_s,
  }.merge!(
    payload
  ).merge!(
    thread:     thread,
    stacktrace: exception.backtrace,
  )
end