Created
December 18, 2010 01:42
-
-
Save knowuh/746023 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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