Sha256: aaf2e23fc8f6cd78ae32eab7b4e6298436b25c7e4b8d1f624746066326177a20

Contents?: true

Size: 882 Bytes

Versions: 1

Compression:

Stored size: 882 Bytes

Contents

require 'logger'

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

    def watchdog(last_words)
      yield
    rescue => ex
      logger.error last_words
      logger.error ex
      logger.error ex.backtrace.join("\n")
    end

    def logger
      Sidekiq::Util.logger
    end

    def redis
      Sidekiq::Manager.redis
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sidekiq-0.6.0 lib/sidekiq/util.rb