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



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/steno/record.rb', line 27

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.



13
14
15
# File 'lib/steno/record.rb', line 13

def data
  @data
end

#fiber_idObject (readonly)

Returns the value of attribute fiber_id.



15
16
17
# File 'lib/steno/record.rb', line 15

def fiber_id
  @fiber_id
end

#fileObject (readonly)

Returns the value of attribute file.



17
18
19
# File 'lib/steno/record.rb', line 17

def file
  @file
end

#linenoObject (readonly)

Returns the value of attribute lineno.



18
19
20
# File 'lib/steno/record.rb', line 18

def lineno
  @lineno
end

#log_levelObject (readonly)

Returns the value of attribute log_level.



11
12
13
# File 'lib/steno/record.rb', line 11

def log_level
  @log_level
end

#messageObject (readonly)

Returns the value of attribute message.



10
11
12
# File 'lib/steno/record.rb', line 10

def message
  @message
end

#methodObject (readonly)

Returns the value of attribute method.



19
20
21
# File 'lib/steno/record.rb', line 19

def method
  @method
end

#process_idObject (readonly)

Returns the value of attribute process_id.



16
17
18
# File 'lib/steno/record.rb', line 16

def process_id
  @process_id
end

#sourceObject (readonly)

Returns the value of attribute source.



12
13
14
# File 'lib/steno/record.rb', line 12

def source
  @source
end

#thread_idObject (readonly)

Returns the value of attribute thread_id.



14
15
16
# File 'lib/steno/record.rb', line 14

def thread_id
  @thread_id
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



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

def timestamp
  @timestamp
end