Module: RoflTrace

Included in:
Rofl
Defined in:
lib/rofl_trace.rb

Overview

this module supplies useful trace output for the logger

Instance Method Summary collapse

Instance Method Details

#rofl_disable_traceObject

disable vm wide tracing



26
27
28
# File 'lib/rofl_trace.rb', line 26

def rofl_disable_trace
  set_trace_func nil
end

#rofl_enable_silent_trace(event_regex = /^(call)/) ⇒ Object

enable vm wide silent tracing



17
18
19
20
21
22
23
# File 'lib/rofl_trace.rb', line 17

def rofl_enable_silent_trace event_regex = /^(call)/
  #this is the Kernel::set_trace_func that we overwrite
  trace_func = Proc.new do |event, file, line, id, binding, classname|
  end
  set_trace_func trace_func
  return
end

#rofl_enable_trace(event_regex = /^(call)/) ⇒ Object

enable vm wide tracing



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

def rofl_enable_trace event_regex = /^(call)/
  #this is the Kernel::set_trace_func that we overwrite
  trace_func = Proc.new do |event, file, line, id, binding, classname|
    if event =~ event_regex
      e = {:event=>event,:file=>file,:line=>line,:id=>id,:binding=>binding,:classname=>classname}
      rofl_trace_event_callback e 
    end
  end
  set_trace_func trace_func
  return
end

#rofl_trace_event_callback(trace_event) ⇒ Object

fires when there is a new trace event



31
32
33
34
# File 'lib/rofl_trace.rb', line 31

def rofl_trace_event_callback trace_event
  puts "new trace:"
  trace_event.each { |n,t| puts "#{n}: #{t.inspect}"}  
end