Sha256: 734c9acb52b7690a0d77a6e3ef838316043d80bf8ac382510eb8ebfe94274b94
Contents?: true
Size: 784 Bytes
Versions: 5
Compression:
Stored size: 784 Bytes
Contents
require 'ansi' require 'yell' module RabbitWQ class WorkLogger def initialize( log_level, path ) @logger = Yell.new do |l| l.level = log_level l.adapter :file, path end end %w( debug error fatal info warn ).each do |level| define_method level do |*args| worker, message = nil, nil if args.size > 1 worker, message = *args else message = args.first end if worker logger.send( level, "[" + ANSI.cyan { "#{worker.class.name}:#{worker.object_id}" } + "] #{message}" ) else logger.send( level, message ) end end end protected attr_reader :logger end end
Version data entries
5 entries across 5 versions & 1 rubygems