Sha256: c0f38b4866c280e4d0b26c8b1312e742634161be93dec6141a826570eabc239b
Contents?: true
Size: 1.33 KB
Versions: 12
Compression:
Stored size: 1.33 KB
Contents
require 'time' require 'logger' module Sidekiq ## # This module is part of Sidekiq core and not intended for extensions. # module Util class Pretty < Logger::Formatter # Provide a call() method that returns the formatted message. def call(severity, time, program_name, message) "#{time.utc.iso8601} #{Process.pid} TID-#{Thread.current.object_id.to_s(36)} #{severity}: #{message}\n" end end def self.logger @logger ||= begin log = Logger.new(STDOUT) log.level = Logger::INFO log.formatter = Pretty.new 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(&block) Sidekiq.redis(&block) end def process_id Process.pid end end end
Version data entries
12 entries across 12 versions & 1 rubygems