Sha256: 0a0cc2908da0e12ae2f9924141761a078e419b87f41b0808d8b913800423177a

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

# encoding: utf-8
require 'rubygems'
require 'log4r'
#require 'log4r/outputter/syslogoutputter'

module RabbitHutch
  class Log4rConsumer
      
    def initialize(rabbitmq_host, config)
      puts "\tInitializing Log4r Consumer"
      @rabbitmq_host = rabbitmq_host
      @config = config
      @log_name = rabbitmq_host["displayname"]
      @config.consumers.each do |consumer|
        if consumer["name"] == 'log4r_consumer'
          @log_prefix = consumer['log_prefix']
          @log_location = consumer['log_location']
        end
      end
      
      @logger = Log4r::Logger.new("#{@log_name}#_log")
      @logger.outputters << Log4r::FileOutputter.new("#{@log_name}_filelog", :filename =>  "#{@log_location}/#{@log_prefix}#{@log_name}.log")
    end
        
    def log_event(item)
      begin  
        @logger.info(item)    
      rescue Exception => e
        puts "Error occurred Message Handler trying to write messages to Log #{e.inspect}" 
        #@log.error("Error occurred Message Handler trying to write messages to MONGODB #{e.inspect}") 
      end
    end 
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rabbithutch-0.0.5 lib/consumers/log4r_consumer.rb
rabbithutch-0.0.3 lib/consumers/log4r_consumer.rb
rabbithutch-0.0.2 lib/consumers/log4r_consumer.rb