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.
98 99 100 |
# File 'lib/appmap/trace.rb', line 98 def initialize @@stacks ||= Hash.new end |
Class Method Details
.depth ⇒ Object
93 94 95 |
# File 'lib/appmap/trace.rb', line 93 def depth (ENV['APPMAP_STACK_DEPTH'] || 20).to_i end |
.enabled? ⇒ Boolean
89 90 91 |
# File 'lib/appmap/trace.rb', line 89 def enabled? ENV['APPMAP_PRINT_STACKS'] == 'true' end |
Instance Method Details
#record(event) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/appmap/trace.rb', line 102 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 |