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:
parent
acfc0859c4
commit
37b78320da
1 changed files with 9 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue