Skip to content

Instantly share code, notes, and snippets.

@knowuh
Created December 18, 2010 01:42
Show Gist options
  • Save knowuh/746023 to your computer and use it in GitHub Desktop.
Save knowuh/746023 to your computer and use it in GitHub Desktop.
def make_monitor(opts={})
classname_regex = opts[:class_name] || /.*/i
method_regex = opts[:method_name] || /.*/i
monitor = proc { |event, file, line, method, binding, classname|
if (event.to_s =~ /call|return/i)
if method.to_s =~ method_regex
if classname.to_s =~ classname_regex
printf "%8s %s:%-2d %10s %8s\n", event, file, line, method, classname
end
end
end
}
return monitor
end
def set_monitor(monitor)
set_trace_func(monitor)
end
def unset_monitor
set_trace_func nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment