Class: DEBUGGER__::Tracer
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
Color ,
SkipPathHelper
|
|
Inherits: | Object |
Defined in: | lib/debug/tracer.rb |
Class Method Summary
- .new(ui, pattern: nil, into: nil) ⇒ Tracer constructor
Instance Attribute Summary
Instance Method Summary
- #colorize(str, color)
- #description
- #disable
- #enable
- #header(depth)
- #minfo(tp)
- #out(tp, msg = nil, depth = caller.size - 1)
- #puts(msg)
- #skip?(tp) ⇒ Boolean
- #skip_with_pattern?(tp) ⇒ Boolean
- #to_s
Color
- Included
#color_pp | See additional method definition at line 50. |
#colored_inspect, | |
#colorize | See additional method definition at line 36. |
#colorize_blue, | |
#colorize_code | See additional method definition at line 79. |
#colorize_cyan, #colorize_dim, #colorize_magenta, | |
#irb_colorize | See additional method definition at line 27. |
#with_inspection_error_guard |
SkipPathHelper
- Included
Constructor Details
.new(ui, pattern: nil, into: nil) ⇒ Tracer
# File 'lib/debug/tracer.rb', line 19
def initialize ui, pattern: nil, into: nil if /\ADEBUGGER__::(([A-Z][a-z]?)[A-Z][a-z])/ =~ self.class.name @name = $1 @type = $2.downcase end setup if pattern @pattern = Regexp.compile(pattern) else @pattern = nil end if @into = into @output = File.open(into, 'w') @output.puts "PID:#{Process.pid} #{self}" else @output = ui end @key = [@type, @pattern, @into].freeze enable end
Instance Attribute Details
#key (readonly)
[ GitHub ]# File 'lib/debug/tracer.rb', line 17
attr_reader :type, :key
#type (readonly)
[ GitHub ]# File 'lib/debug/tracer.rb', line 17
attr_reader :type, :key
Instance Method Details
#colorize(str, color)
[ GitHub ]# File 'lib/debug/tracer.rb', line 8
def colorize(str, color) # don't colorize trace sent into a file if @into str else super end end
#description
[ GitHub ]# File 'lib/debug/tracer.rb', line 57
def description nil end
#disable
[ GitHub ]# File 'lib/debug/tracer.rb', line 53
def disable @tracer.disable end
#enable
[ GitHub ]# File 'lib/debug/tracer.rb', line 49
def enable @tracer.enable end
#header(depth)
[ GitHub ]# File 'lib/debug/tracer.rb', line 45
def header depth "DEBUGGER (trace/#{@type}) \#th:#{Thread.current.instance_variable_get(:@__thread_client_id)} \#depth:#{'%-2d'%depth}" end
#minfo(tp)
[ GitHub ]# File 'lib/debug/tracer.rb', line 93
def minfo tp return "block{}" if tp.event == :b_call klass = tp.defined_class if klass.singleton_class? "#{tp.self}.#{tp.method_id}" else "#{klass}\##{tp.method_id}" end end
#out(tp, msg = nil, depth = caller.size - 1)
[ GitHub ]# File 'lib/debug/tracer.rb', line 76
def out tp, msg = nil, depth = caller.size - 1 location_str = colorize("#{FrameInfo.pretty_path(tp.path)}:#{tp.lineno}", [:GREEN]) buff = "#{header(depth)}#{msg} at #{location_str}" if false # TODO: Ractor.main? ThreadClient.current.on_trace self.object_id, buff else @output.puts buff @output.flush end end
#puts(msg)
[ GitHub ]# File 'lib/debug/tracer.rb', line 88
def puts msg @output.puts msg @output.flush end
#skip?(tp) ⇒ Boolean
# File 'lib/debug/tracer.rb', line 68
def skip? tp ThreadClient.current.management? || skip_path?(tp.path) || skip_with_pattern?(tp) end
#skip_with_pattern?(tp) ⇒ Boolean
# File 'lib/debug/tracer.rb', line 72
def skip_with_pattern?(tp) @pattern && !tp.path.match?(@pattern) end
#to_s
[ GitHub ]# File 'lib/debug/tracer.rb', line 61
def to_s s = "#{@name}#{description} (#{@tracer.enabled? ? 'enabled' : 'disabled'})" s += " with pattern #{@pattern.inspect}" if @pattern s += " into: #{@into}" if @into s end