1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00
mperham--sidekiq/lib/sidekiq/util.rb

46 lines
882 B
Ruby
Raw Normal View History

require 'logger'
2012-01-22 14:32:38 -05:00
module Sidekiq
module Util
def self.logger
@logger ||= begin
log = Logger.new(STDERR)
log.level = Logger::INFO
log
end
end
def self.logger=(log)
@logger = (log ? log : Logger.new('/dev/null'))
end
def constantize(camel_cased_word)
names = camel_cased_word.split('::')
names.shift if names.empty? || names.first.empty?
constant = Object
names.each do |name|
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
end
constant
end
2012-01-22 14:32:38 -05:00
def watchdog(last_words)
yield
rescue => ex
logger.error last_words
logger.error ex
logger.error ex.backtrace.join("\n")
2012-01-22 14:32:38 -05:00
end
def logger
Sidekiq::Util.logger
2012-01-22 19:01:46 -05:00
end
def redis
Sidekiq::Manager.redis
end
2012-01-22 14:32:38 -05:00
end
end