Sha256: 17b70f3270fdd338314b2c757fbf95ade15585dee3e950195bf7864a8bc0539e

Contents?: true

Size: 940 Bytes

Versions: 40

Compression:

Stored size: 940 Bytes

Contents

require 'logger'

module MailRoom
  module Delivery
    # File/STDOUT Logger Delivery method
    # @author Tony Pitale
    class Logger
      Options = Struct.new(:log_path) do
        def initialize(mailbox)
          log_path = mailbox.log_path || mailbox.delivery_options[:log_path]

          super(log_path)
        end
      end

      # Build a new delivery, hold the delivery options
      #   open a file or stdout for IO depending on the options
      # @param [MailRoom::Delivery::Logger::Options]
      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

      # Write the message to our logger
      # @param message [String] the email message as a string, RFC822 format
      def deliver(message)
        @logger.info message

        true
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 2 rubygems

Version Path
gitlab-mail_room-0.0.25 lib/mail_room/delivery/logger.rb
mail_room-0.11.1 lib/mail_room/delivery/logger.rb
mail_room-0.11.0 lib/mail_room/delivery/logger.rb
gitlab-mail_room-0.0.24 lib/mail_room/delivery/logger.rb
mail_room-0.10.1 lib/mail_room/delivery/logger.rb
gitlab-mail_room-0.0.23 lib/mail_room/delivery/logger.rb
gitlab-mail_room-0.0.22 lib/mail_room/delivery/logger.rb
gitlab-mail_room-0.0.21 lib/mail_room/delivery/logger.rb
gitlab-mail_room-0.0.20 lib/mail_room/delivery/logger.rb
gitlab-mail_room-0.0.19 lib/mail_room/delivery/logger.rb
gitlab-mail_room-0.0.18 lib/mail_room/delivery/logger.rb
gitlab-mail_room-0.0.17 lib/mail_room/delivery/logger.rb
gitlab-mail_room-0.0.16 lib/mail_room/delivery/logger.rb
gitlab-mail_room-0.0.15 lib/mail_room/delivery/logger.rb
gitlab-mail_room-0.0.14 lib/mail_room/delivery/logger.rb
gitlab-mail_room-0.0.13 lib/mail_room/delivery/logger.rb
gitlab-mail_room-0.0.12 lib/mail_room/delivery/logger.rb
gitlab-mail_room-0.0.11 lib/mail_room/delivery/logger.rb
gitlab-mail_room-0.0.10 lib/mail_room/delivery/logger.rb
gitlab-mail_room-0.0.9 lib/mail_room/delivery/logger.rb