Class: Sidekiq::Middleware::Server::Logging

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/middleware/server/logging.rb

Instance Method Summary collapse

Instance Method Details

#call(*args) ⇒ Object


5
6
7
8
9
10
11
12
13
14
# File 'lib/sidekiq/middleware/server/logging.rb', line 5

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

#elapsed(start) ⇒ Object


16
17
18
# File 'lib/sidekiq/middleware/server/logging.rb', line 16

def elapsed(start)
  (Time.now - start).to_f.round(3)
end

#loggerObject


20
21
22
# File 'lib/sidekiq/middleware/server/logging.rb', line 20

def logger
  Sidekiq::Util.logger
end