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