Sha256: e88f8a7eccfab34e04d53604b590f70b4b402a99fa3dc5be6948a3d71f356501
Contents?: true
Size: 876 Bytes
Versions: 2
Compression:
Stored size: 876 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 def level=( level ) # conform to API but do not set log level this way 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, "[" + Rainbow( "#{worker.class.name}:#{worker.object_id}" ).cyan + "] #{message}" ) else logger.send( level, message ) end end end protected attr_reader :logger end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rabbit-wq-2.1.0 | lib/rabbit_wq/work_logger.rb |
rabbit-wq-2.0.0 | lib/rabbit_wq/work_logger.rb |