Class: AMQPLogging::LogDevice
- Inherits:
-
Object
- Object
- AMQPLogging::LogDevice
- Defined in:
- lib/amqp_logging/log_device.rb
Constant Summary collapse
- RETRY_AFTER =
10.seconds
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(opts = {}) ⇒ LogDevice
constructor
A new instance of LogDevice.
- #write(msg) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ LogDevice
Returns a new instance of LogDevice.
7 8 9 |
# File 'lib/amqp_logging/log_device.rb', line 7 def initialize(opts = {}) @configuration = opts end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
4 5 6 |
# File 'lib/amqp_logging/log_device.rb', line 4 def configuration @configuration end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/amqp_logging/log_device.rb', line 5 def logger @logger end |
Instance Method Details
#close ⇒ Object
23 24 25 |
# File 'lib/amqp_logging/log_device.rb', line 23 def close reset_amqp # TODO: Test! end |
#write(msg) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/amqp_logging/log_device.rb', line 11 def write(msg) begin if !@paused || @paused <= RETRY_AFTER.ago routing_key = configuration[:routing_key].respond_to?(:call) ? configuration[:routing_key].call(msg).to_s : configuration[:routing_key] exchange.publish(msg, :key => routing_key) end rescue Exception => exception reraise_expectation_errors! pause_amqp_logging(exception) end end |