Sha256: 0300a124468d40a99953be3a36dee4e12c4f802dd7f929747b26a43e2c216388

Contents?: true

Size: 728 Bytes

Versions: 14

Compression:

Stored size: 728 Bytes

Contents

require 'mail/smtp_envelope'

module Mail
  class LoggerDelivery
    attr_reader :logger, :severity, :settings

    def initialize(settings)
      @settings = settings
      @logger   = settings.fetch(:logger) { default_logger }
      @severity = derive_severity(settings[:severity])
    end

    def deliver!(mail)
      logger.log(severity) { Mail::SmtpEnvelope.new(mail).message }
    end

    private
      def default_logger
        require 'logger'
        ::Logger.new($stdout)
      end

      def derive_severity(severity)
        case severity
        when nil
          Logger::INFO
        when Integer
          severity
        else
          Logger.const_get(severity.to_s.upcase)
        end
      end
  end
end

Version data entries

14 entries across 14 versions & 5 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/logger_delivery.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/logger_delivery.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/logger_delivery.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/logger_delivery.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/logger_delivery.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/logger_delivery.rb
mail-2.8.1 lib/mail/network/delivery_methods/logger_delivery.rb
mail-2.8.1.rc2 lib/mail/network/delivery_methods/logger_delivery.rb
mail-2.8.0.1 lib/mail/network/delivery_methods/logger_delivery.rb
mail-2.8.0.1.rc1 lib/mail/network/delivery_methods/logger_delivery.rb
mail-2.8.0 lib/mail/network/delivery_methods/logger_delivery.rb
mail-2.8.0.rc3 lib/mail/network/delivery_methods/logger_delivery.rb
mail-2.8.0.rc2 lib/mail/network/delivery_methods/logger_delivery.rb
mail-2.8.0.rc1 lib/mail/network/delivery_methods/logger_delivery.rb