Skip to content

Commit 37043bd

Browse files
committed
teeny
1 parent 6c344e6 commit 37043bd

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

‎v4-cokapi/backends/ruby/pg_logger.rb‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,22 @@
33
#
44
# only works on Ruby 2.X since we use the TracePoint API
55

6+
# simple Ruby idiom for assert:
7+
# raise "error msg" unless <condition to assert>
8+
9+
require 'json'
10+
611
script_name = ARGV[0]
712

8-
trace = TracePoint.new(:line,:class,:end,:call,:return,:raise,:b_call,:b_return) do |tp|
9-
if tp.path == '(eval)'
10-
p [tp.event, tp.lineno]
11-
end
13+
cur_trace = []
14+
15+
pg_tracer = TracePoint.new(:line,:class,:end,:call,:return,:raise,:b_call,:b_return) do |tp|
16+
if tp.path != '(eval)' then next end # 'next' is a 'return' from a block
17+
p [tp.event, tp.lineno, tp.path, tp.defined_class, tp.method_id]
18+
# TODO: look into tp.defined_class and tp.method_id attrs
19+
# TODO: look into tp.raised_exception and tp.return_value attrs
1220
end
1321

14-
trace.enable
22+
pg_tracer.enable
1523
eval(File.open(script_name).read) # filename is called '(eval)'
16-
trace.disable
24+
pg_tracer.disable

0 commit comments

Comments
 (0)