Sha256: b2e91e72286febd5c486348f360f708a48ea73845e8bbdafc3b6dcf97b431d61

Contents?: true

Size: 779 Bytes

Versions: 9

Compression:

Stored size: 779 Bytes

Contents

# frozen_string_literal: true

module Cloudenvoy
  # Logger configuration for publishers
  class PublisherLogger < LoggerWrapper
    #
    # The subscriber default context processor.
    #
    # @return [Proc] The context processor proc.
    #
    def self.default_context_processor
      @default_context_processor ||= ->(loggable) { loggable.message&.to_h&.slice(:id, :metadata, :topic) || {} }
    end

    #
    # Format main log message.
    #
    # @param [String] msg The message to log.
    #
    # @return [String] The formatted log message
    #
    def formatted_message(msg)
      [
        '[Cloudenvoy]',
        "[#{loggable.class}]",
        loggable.message&.id ? "[#{loggable.message.id}]" : nil,
        ' ',
        msg
      ].compact.join
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
cloudenvoy-0.5.0 lib/cloudenvoy/publisher_logger.rb
cloudenvoy-0.5.rc1 lib/cloudenvoy/publisher_logger.rb
cloudenvoy-0.4.2 lib/cloudenvoy/publisher_logger.rb
cloudenvoy-0.4.1 lib/cloudenvoy/publisher_logger.rb
cloudenvoy-0.4.0 lib/cloudenvoy/publisher_logger.rb
cloudenvoy-0.3.1 lib/cloudenvoy/publisher_logger.rb
cloudenvoy-0.3.0 lib/cloudenvoy/publisher_logger.rb
cloudenvoy-0.2.0 lib/cloudenvoy/publisher_logger.rb
cloudenvoy-0.1.0 lib/cloudenvoy/publisher_logger.rb