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.



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

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
22
# 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.



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

def appenders
  @appenders
end

Instance Method Details

#startObject

Start the appender thread



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

def start
  return false if active?

  thread
  true
end