Skip to content

Instantly share code, notes, and snippets.

@esumerfd
Created August 26, 2010 19:05
Show Gist options
  • Save esumerfd/551990 to your computer and use it in GitHub Desktop.
Save esumerfd/551990 to your computer and use it in GitHub Desktop.
#
# 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