lib/clockwork/event.rb in clockwork-2.0.4 vs lib/clockwork/event.rb in clockwork-3.0.0
- old
+ new
@@ -53,13 +53,22 @@
job.to_s
end
private
def execute
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
+ error = nil
+
@block.call(@job, @last)
rescue => e
+ error = e
@manager.log_error e
@manager.handle_error e
+ ensure
+ finish = Process.clock_gettime(Process::CLOCK_MONOTONIC)
+ duration = ((finish - start) * 1000).round # milliseconds
+
+ @manager.log "Finished '#{self}' duration_ms=#{duration} error=#{error.inspect}"
end
def elapsed_ready?(t)
@last.nil? || (t - @last.to_i).to_i >= @period
end