Method: SemanticLogger::Appender::Async#initialize

Defined in:
lib/semantic_logger/appender/async.rb

#initialize(appender:, max_queue_size: 10_000, lag_check_interval: 1_000, lag_threshold_s: 30) ⇒ Async

Appender proxy to allow an existing appender to run asynchronously in a separate thread.

Parameters:

max_queue_size: [Integer]
  The maximum number of log messages to hold on the queue before blocking attempts to add to the queue.
  -1: The queue size is uncapped and will never block no matter how long the queue is.
  Default: 10,000

lag_threshold_s [Float]
  Log a warning when a log message has been on the queue for longer than this period in seconds.
  Default: 30

lag_check_interval: [Integer]
  Number of messages to process before checking for slow logging.
  Default: 1,000


39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/semantic_logger/appender/async.rb', line 39

def initialize(appender:,
               max_queue_size: 10_000,
               lag_check_interval: 1_000,
               lag_threshold_s: 30)

  @appender           = appender
  @lag_check_interval = lag_check_interval
  @lag_threshold_s    = lag_threshold_s
  @thread             = nil
  @max_queue_size     = max_queue_size
  create_queue
  thread
end