Class: AppMap::StackPrinter
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ StackPrinter
constructor
A new instance of StackPrinter.
- #record(event) ⇒ Object
Constructor Details
#initialize ⇒ StackPrinter
Returns a new instance of StackPrinter.
116 117 118 |
# File 'lib/appmap/trace.rb', line 116 def initialize @@stacks ||= Hash.new end |
Class Method Details
.depth ⇒ Object
111 112 113 |
# File 'lib/appmap/trace.rb', line 111 def depth (ENV['APPMAP_STACK_DEPTH'] || 20).to_i end |
.enabled? ⇒ Boolean
107 108 109 |
# File 'lib/appmap/trace.rb', line 107 def enabled? ENV['APPMAP_PRINT_STACKS'] == 'true' end |
Instance Method Details
#record(event) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/appmap/trace.rb', line 120 def record(event) stack = caller.select { |line| !line.index('/lib/appmap/') }[0...StackPrinter.depth].join("\n ") stack_hash = Digest::SHA256.hexdigest(stack) unless @@stacks[stack_hash] @@stacks[stack_hash] = stack puts puts 'Event: ' + event.to_h.map { |k, v| [ "#{k}: #{v}" ] }.join(", ") puts ' ' + stack puts end end |