Class: MailRoom::Delivery::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/mail_room/delivery/logger.rb

Overview

File/STDOUT Logger Delivery method

Author:

  • Tony Pitale

Defined Under Namespace

Classes: Options

Instance Method Summary collapse

Constructor Details

#initialize(delivery_options) ⇒ Logger

Build a new delivery, hold the delivery options

open a file or stdout for IO depending on the options

19
20
21
22
23
24
25
26
# File 'lib/mail_room/delivery/logger.rb', line 19

def initialize(delivery_options)
  io = File.open(delivery_options.log_path, 'a') if delivery_options.log_path
  io ||= STDOUT

  io.sync = true

  @logger = ::Logger.new(io)
end

Instance Method Details

#deliver(message) ⇒ Object

Write the message to our logger

Parameters:

  • message (String)

    the email message as a string, RFC822 format


30
31
32
33
34
# File 'lib/mail_room/delivery/logger.rb', line 30

def deliver(message)
  @logger.info message

  true
end