1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

log_writer.rb - add internal_write method (#2888)

This commit is contained in:
MSP-Greg 2022-05-31 19:28:43 -05:00 committed by GitHub
parent acfc0859c4
commit 37b78320da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -57,18 +57,22 @@ module Puma
# Write +str+ to +@stdout+
def log(str)
@stdout.is_a?(IO) and @stdout.wait_writable(1)
@stdout.puts(format(str)) if @stdout.respond_to? :puts
@stdout.flush unless @stdout.sync
rescue Errno::EPIPE, Errno::EBADF
if @stdout.respond_to? :puts
internal_write { @stdout.puts format(str) }
end
end
def write(str)
internal_write { @stdout.write format(str) }
end
def internal_write
@stdout.is_a?(IO) and @stdout.wait_writable(1)
@stdout.write(format(str))
yield
@stdout.flush unless @stdout.sync
rescue Errno::EPIPE, Errno::EBADF
end
private :internal_write
def debug(str)
log("% #{str}") if @debug