Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (23 sloc) 736 Bytes
#!/usr/bin/env ruby
require 'bunny'
abort "Usage: #{$PROGRAM_NAME} [binding key]" if ARGV.empty?
connection = Bunny.new(automatically_recover: false)
connection.start
channel = connection.create_channel
exchange = channel.topic('topic_logs')
queue = channel.queue('', exclusive: true)
ARGV.each do |severity|
queue.bind(exchange, routing_key: severity)
end
puts ' [*] Waiting for logs. To exit press CTRL+C'
begin
# block: true is only used to keep the main thread
# alive. Please avoid using it in real world applications.
queue.subscribe(block: true) do |delivery_info, _properties, body|
puts " [x] #{delivery_info.routing_key}:#{body}"
end
rescue Interrupt => _
channel.close
connection.close
exit(0)
end
You can’t perform that action at this time.