Skip to content

Commit 3e9e3d7

Browse files
committed
refactor(tracer): unnest event handlers
1 parent 04b0e85 commit 3e9e3d7

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

gems/pure-ruby-tracer/lib/trace.rb

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -182,38 +182,38 @@ def record_return(tp)
182182
@record.register_variable("<return_value>", return_value)
183183
@record.events << [:Return, ReturnRecord.new(return_value)]
184184
end
185+
end
185186

186-
def record_step(tp)
187-
if self.tracks_call?(tp)
188-
@record.register_step(tp.path, tp.lineno)
189-
variables = self.load_variables(tp.binding)
190-
variables.each do |(name, value)|
191-
@record.register_variable(name, value)
192-
end
187+
def record_step(tp)
188+
if self.tracks_call?(tp)
189+
@record.register_step(tp.path, tp.lineno)
190+
variables = self.load_variables(tp.binding)
191+
variables.each do |(name, value)|
192+
@record.register_variable(name, value)
193193
end
194194
end
195+
end
195196

196-
def record_event(caller, content)
197-
# reason/effect are on different steps:
198-
# reason: before `p` is called;
199-
# effect: now, when the args are evaluated
200-
# which can happen after many calls/steps;
201-
# maybe add a step for this call?
202-
begin
203-
location = caller[0].split[0].split(':')[0..1]
204-
path, line = location[0], location[1].to_i
205-
@record.register_step(path, line)
206-
rescue
207-
# ignore for now: we'll just jump to last previous step
208-
# which might be from args
209-
end
210-
# start is last step on this level: log for reason: the previous step on this level
211-
@record.events << [:Event, RecordEvent.new(EVENT_KIND_WRITE, content, "")]
197+
def record_event(caller, content)
198+
# reason/effect are on different steps:
199+
# reason: before `p` is called;
200+
# effect: now, when the args are evaluated
201+
# which can happen after many calls/steps;
202+
# maybe add a step for this call?
203+
begin
204+
location = caller[0].split[0].split(':')[0..1]
205+
path, line = location[0], location[1].to_i
206+
@record.register_step(path, line)
207+
rescue
208+
# ignore for now: we'll just jump to last previous step
209+
# which might be from args
212210
end
211+
# start is last step on this level: log for reason: the previous step on this level
212+
@record.events << [:Event, RecordEvent.new(EVENT_KIND_WRITE, content, "")]
213+
end
213214

214-
def record_exception(tp)
215-
@record.events << [:Event, RecordEvent.new(EVENT_KIND_ERROR, tp.raised_exception.to_s, "")]
216-
end
215+
def record_exception(tp)
216+
@record.events << [:Event, RecordEvent.new(EVENT_KIND_ERROR, tp.raised_exception.to_s, "")]
217217
end
218218

219219
def activate

0 commit comments

Comments
 (0)