Class: Logfoo::LogLine

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

#levelObject

Returns the value of attribute level

Returns:

  • (Object)

    the current value of level



2
3
4
# File 'lib/logfoo/entries.rb', line 2

def level
  @level
end

#logger_nameObject

Returns the value of attribute logger_name

Returns:

  • (Object)

    the current value of logger_name



2
3
4
# File 'lib/logfoo/entries.rb', line 2

def logger_name
  @logger_name
end

#messageObject

Returns the value of attribute message

Returns:

  • (Object)

    the current value of message



2
3
4
# File 'lib/logfoo/entries.rb', line 2

def message
  @message
end

#payloadObject

Returns the value of attribute payload

Returns:

  • (Object)

    the current value of payload



2
3
4
# File 'lib/logfoo/entries.rb', line 2

def payload
  @payload
end

#threadObject

Returns the value of attribute thread

Returns:

  • (Object)

    the current value of thread



2
3
4
# File 'lib/logfoo/entries.rb', line 2

def thread
  @thread
end

#timeObject

Returns the value of attribute time

Returns:

  • (Object)

    the current value of time



2
3
4
# File 'lib/logfoo/entries.rb', line 2

def time
  @time
end

Class Method Details

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



4
5
6
7
8
9
10
11
12
13
# File 'lib/logfoo/entries.rb', line 4

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

Instance Method Details

#to_hObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/logfoo/entries.rb', line 16

def to_h
  {
    level:   level,
    time:    time,
    msg:     message,
    logger:  logger_name,
  }.merge!(
    payload
  ).merge!(
    thread:  thread
  )
end