Class: Kitchen::Logger::LineBuffer

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/logger.rb

Overview

Buffers streamed output until a complete line is available for logging.

Instance Method Summary collapse

Constructor Details

#initialize(&line_handler) ⇒ LineBuffer

Returns a new instance of LineBuffer.



486
487
488
489
# File 'lib/kitchen/logger.rb', line 486

def initialize(&line_handler)
  @buffer = +""
  @line_handler = line_handler
end

Instance Method Details

#<<(msg) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Appends a chunk of stream output to the buffer, emitting each complete newline-terminated line to the line handler.

Parameters:

  • msg (String)

    a chunk of stream output, which may contain zero or more complete lines



498
499
500
501
# File 'lib/kitchen/logger.rb', line 498

def <<(msg)
  @buffer += msg
  flush_lines
end