Mixin used internally for the FastCommunicator and SlowCommunicator wrappers that hide implementation complexity from log writer subclasses.

Methods
C
D
N
Class Public methods
new( writer_instance, owning_logger )

Create an instance of a logging communicator, based on the given log writer and owning logger instance.

writer_instance

Hoodoo::Logger::FastWriter or Hoodoo::Logger::SlowWriter subclass instance that will log things when this Communicator asks it to do so.

owning_logger

Hoodoo::Logger instance that will be using this communicator instance.

# File lib/hoodoo/logger/logger.rb, line 369
def initialize( writer_instance, owning_logger )
  @writer_instance = writer_instance
  @owning_logger   = owning_logger
end
Instance Public methods
communicate( payload )

Implement Hoodoo::Communicators::Base#communicate for both slow and fast writers. Assumes it will be passed a Hoodoo::Logger::Payload class instance which describes the structured log data to report; also assumes it is only called when the calling logger's configured log level threshold should allow through the level of the log message in question. Calls through to the report implementation.

# File lib/hoodoo/logger/logger.rb, line 381
def communicate( payload )
  @writer_instance.report(
    payload.log_level,
    payload.component,
    payload.code,
    payload.data
  )
end
dropped( number )

Implement optional method Hoodoo::Communicators::Slow#dropped on behalf of subclasses. The method turns the 'messages dropped' notification into a log message of :warn level and which it reports internally immediately for the Writer instance only (since different writers have different queues and thus different dropped message warnings), provided that the owning Hoodoo::Logger instance log level lets warnings through.

# File lib/hoodoo/logger/logger.rb, line 398
def dropped( number )
  if @owning_logger.report?( :warn )
    @writer_instance.report(
      :warn,
      self.class.name,
      'dropped.messages',
      "Logging flooded - #{ number } messages dropped"
    )
  end
end