diff --git a/sylvilagus/jruby/lib/sylvilagus/ch03/log_listeners.rb b/sylvilagus/jruby/lib/sylvilagus/ch03/log_listeners.rb index 9501f97..f3c8055 100644 --- a/sylvilagus/jruby/lib/sylvilagus/ch03/log_listeners.rb +++ b/sylvilagus/jruby/lib/sylvilagus/ch03/log_listeners.rb @@ -8,6 +8,8 @@ import org.jruby.RubyString class Sylvilagus::Ch03::LogListeners class LogConsumer < DefaultConsumer + attr_accessor :level + def handleDelivery(consumer_tag, envelope, properties, body) body_string = RubyString.bytes_to_string(body) puts "#{level}: #{body_string}" @@ -45,8 +47,11 @@ class Sylvilagus::Ch03::LogListeners channel.queue_bind(info_queue, 'amq.rabbitmq.log', 'info') errors_consumer = LogConsumer.new(channel) + errors_consumer.level = 'error' warnings_consumer = LogConsumer.new(channel) + warnings_consumer.level = 'warning' info_consumer = LogConsumer.new(channel) + info_consumer.level = 'info' puts 'Setting up consumers...' channel.basic_consume(errors_queue, false, errors_consumer)