Class: LogStash::IOWrappedLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/patches/puma.rb

Overview

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.

Instance Method Summary collapse

Constructor Details

#initialize(new_logger) ⇒ IOWrappedLogger

Returns a new instance of IOWrappedLogger.



15
16
17
18
# File 'lib/logstash/patches/puma.rb', line 15

def initialize(new_logger)
  @logger_lock = Mutex.new
  @logger = new_logger
end

Instance Method Details

#logger=(logger) ⇒ Object



24
25
26
# File 'lib/logstash/patches/puma.rb', line 24

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

#puts(str) ⇒ Object Also known as: write, <<



28
29
30
31
# File 'lib/logstash/patches/puma.rb', line 28

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

#sync=(v) ⇒ Object



20
21
22
# File 'lib/logstash/patches/puma.rb', line 20

def sync=(v)
  # noop
end