Class: Creeper::Middleware::Server::Logging
- Inherits:
-
Object
- Object
- Creeper::Middleware::Server::Logging
- Defined in:
- lib/creeper/middleware/server/logging.rb
Instance Method Summary collapse
Instance Method Details
#call(worker, msg, queue, job, conn) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/creeper/middleware/server/logging.rb', line 6 def call(worker, msg, queue, job, conn) Creeper::Logging.with_context("#{worker.class.to_s} JOB-#{job.id rescue nil} MSG-#{worker.object_id.to_s(36)}") do begin start = Time.now logger.info { "start" } yield logger.info { "done: #{elapsed(start)} sec" } rescue logger.info { "fail: #{elapsed(start)} sec" } raise end end end |
#elapsed(start) ⇒ Object
20 21 22 |
# File 'lib/creeper/middleware/server/logging.rb', line 20 def elapsed(start) (Time.now - start).to_f.round(3) end |