Sha256: 9df63de2e0c1e6c5542e885e4c9238e1235279f4aaedfe6ea456ad22a4923638

Contents?: true

Size: 1.17 KB

Versions: 170

Compression:

Stored size: 1.17 KB

Contents

# encoding: utf-8
#
# Patch to replace the usage of STDERR and STDOUT
# see: https://github.com/elastic/logstash/issues/5912
module LogStash
  class NullLogger
    def self.debug(message)
    end
  end

  # Puma uses by default the STDERR an the STDOUT for all his error
  # handling, the server class accept custom a events object that can accept custom io object,
  # so I just wrap the logger into an IO like object.
  class IOWrappedLogger
    def initialize(new_logger)
      @logger_lock = Mutex.new
      @logger = new_logger
    end

    def sync=(v)
      # noop
    end

    def logger=(logger)
      @logger_lock.synchronize { @logger = logger }
    end

    def puts(str)
      # The logger only accept a str as the first argument
      @logger_lock.synchronize { @logger.debug(str.to_s) }
    end
    alias_method :write, :puts
    alias_method :<<, :puts
  end

end

# Reopen the puma class to create a scoped STDERR and STDOUT
# This operation is thread safe since its done at the class level
# and force JRUBY to flush his classes cache.
module Puma
  STDERR = LogStash::IOWrappedLogger.new(LogStash::NullLogger)
  STDOUT = LogStash::IOWrappedLogger.new(LogStash::NullLogger)
end

Version data entries

170 entries across 167 versions & 12 rubygems

Version Path
logstash-core-5.6.15-java lib/logstash/patches/puma.rb
logstash-core-7.0.0.beta1-java lib/logstash/patches/puma.rb
logstash-core-6.6.0-java lib/logstash/patches/puma.rb
logstash-core-7.0.0.alpha2-java lib/logstash/patches/puma.rb
logstash-core-6.5.4-java lib/logstash/patches/puma.rb
logstash-core-6.5.3-java lib/logstash/patches/puma.rb
logstash-core-5.6.14-java lib/logstash/patches/puma.rb
logstash-core-6.5.2-java lib/logstash/patches/puma.rb
logstash-core-6.5.1-java lib/logstash/patches/puma.rb
logstash-core-7.0.0.alpha1-java lib/logstash/patches/puma.rb
logstash-core-6.5.0-java lib/logstash/patches/puma.rb
logstash-core-5.6.13-java lib/logstash/patches/puma.rb
logstash-core-6.4.3-java lib/logstash/patches/puma.rb
logstash-core-6.4.2-java lib/logstash/patches/puma.rb
logstash-core-5.6.12-java lib/logstash/patches/puma.rb
logstash-core-6.4.1-java lib/logstash/patches/puma.rb
logstash-core-6.4.0-java lib/logstash/patches/puma.rb
logstash-core-5.6.11-java lib/logstash/patches/puma.rb
logstash-core-6.3.2-java lib/logstash/patches/puma.rb
logstash-core-6.3.1-java lib/logstash/patches/puma.rb