Class: Steno::Record

Inherits:
Object show all
Defined in:
lib/steno/record.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, log_level, message, loc = [], data = {}) ⇒ Record

Returns a new instance of Record.

Parameters:

  • source (String)

    Identifies message source.

  • log_level (Symbol)
  • message (String)
  • loc (Array) (defaults to: [])

    Location where the record was generated. Format is [<filename>, <lineno>, <method>].

  • data (Hash) (defaults to: {})

    User-supplied data



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/steno/record.rb', line 17

def initialize(source, log_level, message, loc = [], data = {})
  raise 'Log level must be a Symbol' unless log_level.is_a? Symbol

  @timestamp  = Time.now
  @source     = source
  @log_level  = log_level
  @message    = message.to_s
  @data       = {}.merge(data)
  @thread_id  = Thread.current.object_id
  @fiber_id   = Fiber.current.object_id
  @process_id = Process.pid

  @file, @lineno, @method = loc
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



8
9
10
# File 'lib/steno/record.rb', line 8

def data
  @data
end

#fiber_idObject (readonly)

Returns the value of attribute fiber_id.



8
9
10
# File 'lib/steno/record.rb', line 8

def fiber_id
  @fiber_id
end

#fileObject (readonly)

Returns the value of attribute file.



8
9
10
# File 'lib/steno/record.rb', line 8

def file
  @file
end

#linenoObject (readonly)

Returns the value of attribute lineno.



8
9
10
# File 'lib/steno/record.rb', line 8

def lineno
  @lineno
end

#log_levelObject (readonly)

Returns the value of attribute log_level.



8
9
10
# File 'lib/steno/record.rb', line 8

def log_level
  @log_level
end

#messageObject (readonly)

Returns the value of attribute message.



8
9
10
# File 'lib/steno/record.rb', line 8

def message
  @message
end

#methodObject (readonly)

Returns the value of attribute method.



8
9
10
# File 'lib/steno/record.rb', line 8

def method
  @method
end

#process_idObject (readonly)

Returns the value of attribute process_id.



8
9
10
# File 'lib/steno/record.rb', line 8

def process_id
  @process_id
end

#sourceObject (readonly)

Returns the value of attribute source.



8
9
10
# File 'lib/steno/record.rb', line 8

def source
  @source
end

#thread_idObject (readonly)

Returns the value of attribute thread_id.



8
9
10
# File 'lib/steno/record.rb', line 8

def thread_id
  @thread_id
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



8
9
10
# File 'lib/steno/record.rb', line 8

def timestamp
  @timestamp
end