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-6.8.23-java lib/logstash/patches/puma.rb
logstash-core-6.8.22-java lib/logstash/patches/puma.rb
logstash-core-6.8.21-java lib/logstash/patches/puma.rb
logstash-core-6.8.20-java lib/logstash/patches/puma.rb
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/patches/puma.rb
logstash-core-6.8.19-java lib/logstash/patches/puma.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/patches/puma.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/patches/puma.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/patches/puma.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/patches/puma.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/patches/puma.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/patches/puma.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/patches/puma.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/patches/puma.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/patches/puma.rb
logstash-core-6.8.18-java lib/logstash/patches/puma.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/patches/puma.rb
logstash-core-6.8.17-java lib/logstash/patches/puma.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/patches/puma.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/lib/logstash/patches/puma.rb