Class: Warren::Handler::Log::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/warren/handler/log.rb

Overview

Mimics a Broadcast::Channel but instead passes out to a logger

Instance Method Summary collapse

Constructor Details

#initialize(logger, routing_key_template: '%s') ⇒ Channel

Returns a new instance of Channel.



12
13
14
15
# File 'lib/warren/handler/log.rb', line 12

def initialize(logger, routing_key_template: '%s')
  @logger = logger
  @routing_key_template = routing_key_template
end

Instance Method Details

#<<(message) ⇒ Warren::Handler::Broadcast::Channel

Logs ‘message` to the configured logger

Parameters:

  • message (#routing_key, #payload)

    A message should respond to routing_key and payload. @see Warren::Message::Full

Returns:



24
25
26
27
28
# File 'lib/warren/handler/log.rb', line 24

def <<(message)
  @logger.info "Published: #{key_for(message)}"
  @logger.debug "Payload: #{message.payload}"
  self
end

#exchange(name, options) ⇒ Object



30
31
32
33
# File 'lib/warren/handler/log.rb', line 30

def exchange(name, options)
  @logger.debug "Declared exchange: #{name}, #{options.inspect}"
  Exchange.new(name, options)
end

#prefetch(number) ⇒ Object

NOOP - Provided for API compatibility



41
# File 'lib/warren/handler/log.rb', line 41

def prefetch(number); end

#queue(name, options) ⇒ Object



35
36
37
38
# File 'lib/warren/handler/log.rb', line 35

def queue(name, options)
  @logger.debug "Declared queue: #{name}, #{options.inspect}"
  Queue.new(@logger, name)
end