File tree 3 files changed +84
-0
lines changed
3 files changed +84
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ require "amqp"
5
+
6
+ AMQP . start ( :host => "localhost" ) do |connection |
7
+ channel = AMQP ::Channel . new ( connection )
8
+ exchange = channel . fanout ( "logs" )
9
+ queue = channel . queue ( "" , :exclusive => true )
10
+
11
+ queue . bind ( exchange )
12
+
13
+ Signal . trap ( "INT" ) do
14
+ connection . close do
15
+ EM . stop { exit }
16
+ end
17
+ end
18
+
19
+ puts " [*] Waiting for logs. To exit press CTRL+C"
20
+
21
+ queue . subscribe do |body |
22
+ puts " [x] #{ body } "
23
+ end
24
+ end
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ require "amqp"
5
+
6
+ AMQP . start ( :host => "localhost" ) do |connection |
7
+ channel = AMQP ::Channel . new ( connection )
8
+ exchange = channel . direct ( "direct_logs" )
9
+ queue = channel . queue ( "" , :exclusive => true )
10
+
11
+ if ARGV . empty?
12
+ abort "Usage: #{ $0} [info] [warning] [error]"
13
+ end
14
+
15
+ ARGV . each do |severity |
16
+ queue . bind ( exchange , :routing_key => severity )
17
+ end
18
+
19
+ Signal . trap ( "INT" ) do
20
+ connection . close do
21
+ EM . stop { exit }
22
+ end
23
+ end
24
+
25
+ puts " [*] Waiting for logs. To exit press CTRL+C"
26
+
27
+ queue . subscribe do |header , body |
28
+ puts " [x] #{ header . routing_key } :#{ body } "
29
+ end
30
+ end
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ require "amqp"
5
+
6
+ AMQP . start ( :host => "localhost" ) do |connection |
7
+ channel = AMQP ::Channel . new ( connection )
8
+ exchange = channel . topic ( "topic_logs" )
9
+ queue = channel . queue ( "" , :exclusive => true )
10
+
11
+ if ARGV . empty?
12
+ abort "Usage: #{ $0} [binding key]"
13
+ end
14
+
15
+ ARGV . each do |binding_key |
16
+ queue . bind ( exchange , :routing_key => binding_key )
17
+ end
18
+
19
+ Signal . trap ( "INT" ) do
20
+ connection . close do
21
+ EM . stop { exit }
22
+ end
23
+ end
24
+
25
+ puts " [*] Waiting for logs. To exit press CTRL+C"
26
+
27
+ queue . subscribe do |header , body |
28
+ puts " [x] #{ header . routing_key } :#{ body } "
29
+ end
30
+ end
You can’t perform that action at this time.
0 commit comments