Class: Cloudenvoy::PublisherLogger

Inherits:
LoggerWrapper show all
Defined in:
lib/cloudenvoy/publisher_logger.rb

Overview

Logger configuration for publishers

Instance Attribute Summary

Attributes inherited from LoggerWrapper

#loggable

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from LoggerWrapper

#context_processor, #debug, #error, #fatal, #info, #initialize, #log_block, #logger, #method_missing, #respond_to_missing?

Constructor Details

This class inherits a constructor from Cloudenvoy::LoggerWrapper

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Cloudenvoy::LoggerWrapper

Class Method Details

.default_context_processorProc

The subscriber default context processor.

Returns:

  • (Proc)

    The context processor proc.



11
12
13
# File 'lib/cloudenvoy/publisher_logger.rb', line 11

def self.default_context_processor
  @default_context_processor ||= ->(loggable) { loggable.message.to_h&.slice(:id, :metadata, :topic) || {} }
end

Instance Method Details

#formatted_message(msg) ⇒ String

Format main log message.

Parameters:

  • msg (String)

    The message to log.

Returns:

  • (String)

    The formatted log message



22
23
24
25
26
27
28
29
30
# File 'lib/cloudenvoy/publisher_logger.rb', line 22

def formatted_message(msg)
  [
    '[Cloudenvoy]',
    "[#{loggable.class}]",
    loggable.message&.id ? "[#{loggable.message.id}]" : nil,
    ' ',
    msg
  ].compact.join
end