Sha256: 742b5a6fc1173fb8086e759dfceeb43b89c92f4c5976ef337470d7380df2f1ed

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

module SemanticLogger
  # Thread that submits and processes log requests
  class SyncProcessor
    extend Forwardable

    # Forward methods that can be called directly
    def_delegator :@appenders, :add
    def_delegator :@appenders, :log
    def_delegator :@appenders, :flush
    def_delegator :@appenders, :close
    def_delegator :@appenders, :reopen

    # Allow the internal logger to be overridden from its default of $stderr
    #   Can be replaced with another Ruby logger or Rails logger, but never to
    #   SemanticLogger::Logger itself since it is for reporting problems
    #   while trying to log to the various appenders
    class << self
      attr_writer :logger
    end

    # Internal logger for SemanticLogger
    #   For example when an appender is not working etc..
    #   By default logs to $stderr
    def self.logger
      @logger ||=
        begin
          l      = SemanticLogger::Appender::IO.new($stderr, level: :warn)
          l.name = name
          l
        end
    end

    attr_reader :appenders

    def initialize(appenders = nil)
      @appenders = appenders || Appenders.new(self.class.logger.dup)
    end

    def start
      # NOP
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
semantic_logger-4.11.0 lib/semantic_logger/sync_processor.rb
semantic_logger-4.10.0 lib/semantic_logger/sync_processor.rb
semantic_logger-4.9.0 lib/semantic_logger/sync_processor.rb