2012-02-25 16:43:53 -05:00
|
|
|
module Sidekiq
|
|
|
|
module Middleware
|
|
|
|
module Server
|
|
|
|
class Logging
|
2012-05-12 17:00:42 -04:00
|
|
|
|
2012-02-25 16:43:53 -05:00
|
|
|
def call(*args)
|
|
|
|
static = "#{args[0].class.to_s} MSG-#{args[0].object_id.to_s(36)}" if logger.info?
|
|
|
|
start = Time.now
|
|
|
|
logger.info { "#{static} start" }
|
|
|
|
yield
|
|
|
|
logger.info { "#{static} done: #{elapsed(start)} sec" }
|
|
|
|
rescue
|
|
|
|
logger.info { "#{static} fail: #{elapsed(start)} sec" }
|
|
|
|
raise
|
|
|
|
end
|
|
|
|
|
|
|
|
def elapsed(start)
|
|
|
|
(Time.now - start).to_f.round(3)
|
|
|
|
end
|
|
|
|
|
|
|
|
def logger
|
2012-05-12 17:00:42 -04:00
|
|
|
Sidekiq::Logger.logger
|
2012-02-25 16:43:53 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|