Class: SemanticLogger::Processor

Inherits:
Appender::Async show all
Defined in:
lib/semantic_logger/processor.rb

Overview

Thread that submits and processes log requests

Class Attribute Summary collapse

Instance Attribute Summary collapse

Attributes inherited from Appender::Async

#appender, #lag_check_interval, #lag_threshold_s, #max_queue_size, #queue

Instance Method Summary collapse

Methods inherited from Appender::Async

#active?, #capped?, #close, #flush, #log, #reopen, #thread

Constructor Details

#initialize(max_queue_size: -1)) ⇒ Processor

Returns a new instance of Processor.



25
26
27
28
# File 'lib/semantic_logger/processor.rb', line 25

def initialize(max_queue_size: -1)
  @appenders = Appenders.new(self.class.logger.dup)
  super(appender: @appenders, max_queue_size: max_queue_size)
end

Class Attribute Details

.loggerObject

Internal logger for SemanticLogger

For example when an appender is not working etc..
By default logs to STDERR


15
16
17
18
19
20
21
# File 'lib/semantic_logger/processor.rb', line 15

def self.logger
  @logger ||= begin
    l      = SemanticLogger::Appender::File.new(io: STDERR, level: :warn)
    l.name = name
    l
  end
end

Instance Attribute Details

#appendersObject (readonly)

Returns the value of attribute appenders.



23
24
25
# File 'lib/semantic_logger/processor.rb', line 23

def appenders
  @appenders
end

Instance Method Details

#startObject

Start the appender thread



31
32
33
34
35
# File 'lib/semantic_logger/processor.rb', line 31

def start
  return false if active?
  thread
  true
end