Class: Rookout::Processor::Namespaces::TracebackNamespace

Inherits:
Namespace
  • Object
show all
Defined in:
lib/rookout/processor/namespaces/traceback_namespace.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Namespace

#call_method, #read_attribute, #write_attribute

Constructor Details

#initialize(stack_trace, offset, depth) ⇒ TracebackNamespace

Returns a new instance of TracebackNamespace.



9
10
11
12
13
14
# File 'lib/rookout/processor/namespaces/traceback_namespace.rb', line 9

def initialize stack_trace, offset, depth
  super()
  @stack_trace = stack_trace
  @offset = offset
  @depth = depth
end

Instance Attribute Details

#depthObject (readonly)

Returns the value of attribute depth.



18
19
20
# File 'lib/rookout/processor/namespaces/traceback_namespace.rb', line 18

def depth
  @depth
end

#offsetObject (readonly)

Returns the value of attribute offset.



17
18
19
# File 'lib/rookout/processor/namespaces/traceback_namespace.rb', line 17

def offset
  @offset
end

#stack_traceObject (readonly)

Returns the value of attribute stack_trace.



16
17
18
# File 'lib/rookout/processor/namespaces/traceback_namespace.rb', line 16

def stack_trace
  @stack_trace
end

Instance Method Details

#dump(_log_object_errors) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rookout/processor/namespaces/traceback_namespace.rb', line 24

def dump _log_object_errors
  traceback = Com::Rookout::Variant::Traceback.new

  @depth.times do |i|
    position = i + @offset
    break if position >= @stack_trace.length
    frame_info = @stack_trace[position]

    code_object = Com::Rookout::Variant::CodeObject.new filename: frame_info.path,
                                                        lineno: frame_info.lineno,
                                                        name: frame_info.label

    traceback.locations << code_object
  end

  Com::Rookout::Variant.new variant_type: :VARIANT_TRACEBACK, traceback: traceback
end

#read_key(key) ⇒ Object



20
21
22
# File 'lib/rookout/processor/namespaces/traceback_namespace.rb', line 20

def read_key key
  FrameNamespace.new nil, @stack_trace[key + @offset]
end