module QdLogger

Attributes

logger[RW]

Public Instance Methods

initialize_logger(logger = nil) click to toggle source
# File lib/queue_dispatcher/qd_logger.rb, line 4
def initialize_logger(logger = nil)
  @logger = logger || Logger.new("#{File.expand_path(Rails.root)}/log/queue_dispatcher.log")
end
log(args = {}) click to toggle source

Write a standart log message

# File lib/queue_dispatcher/qd_logger.rb, line 9
def log(args = {})
  sev = args[:sev] || :info
  msg = Time.now.to_s + " #{sev.to_s.upcase} #{$$} (#{self.class.name}): " + args[:msg]
  logger.send(sev, msg) if logger
  puts "#{sev.to_s.upcase}: #{args[:msg]}" if logger.nil? || args[:print_log]
end