Created
August 26, 2010 19:05
-
-
Save esumerfd/551990 to your computer and use it in GitHub Desktop.
This file contains 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
# | |
# Enable ruby call tracing and filter to calls that are in your project or file or class name or an event, etc | |
# | |
# Copy this into your .irbrc for use when you need it. | |
# | |
# trace_on("my_project") | |
# | |
def trace_on(filter = nil) | |
set_trace_func proc { |event, file, line, id, binding, classname| | |
line = sprintf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname | |
puts line if line =~ /#{filter}/ && line !~ /[\(\/]irb[\)\/\.]/ | |
} | |
end | |
def trace_off | |
set_trace_func nil | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment