Sha256: 2f58d6be0677861584c77a19607dc5f745043148885fd9510f8df032324deb44

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module DispatchRider
  module Logging
    class Translator
      class BaseTranslator
        def initialize(message)
          @message = message
        end

        def translate
          raise NotImplementedError, 'Translators must implement #translate'
        end

        private

        def message_info_fragment(message)
          {
            guid: message.guid.to_s,
            subject: message.subject,
            body: message_info_arguments(message),
          }
        end

        def message_info_arguments(message)
          message.body.dup.tap do |m|
            m.delete('guid')
            m.delete('object_id')
          end
        end

        def exception_info_fragment(message, exception)
          exception_details = {
            exception: {
              class: exception.class.to_s,
              message: exception.message,
            }
          }
          message_info_fragment(message).merge exception_details
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dispatch-rider-2.2.0 lib/dispatch-rider/logging/translator/base_translator.rb