Class: Processor::Messenger

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/processor/messenger.rb

Instance Method Summary collapse

Constructor Details

#initialize(level = :info, file = STDOUT, sender = nil) ⇒ Messenger

Returns a new instance of Messenger.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/processor/messenger.rb', line 6

def initialize(level = :info, file = STDOUT, sender = nil)
  @sender = sender
  if level == :null
    file = "/dev/null"
    level = :fatal
  end

  log_level = Logger.const_get(level.upcase);

  logger = ::Logger.new(file).tap do |logger|
    logger.formatter = method(:format_message)
    logger.level = log_level
  end

  super logger
end

Instance Method Details

#message(*args) ⇒ Object



30
31
32
# File 'lib/processor/messenger.rb', line 30

def message(*args)
  self.info *args
end