Class: Kitchen::Logger::StreamLineFormatter

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

Overview

Rewrites already-prefixed stream lines into the matching logger call.

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ StreamLineFormatter

Returns a new instance of StreamLineFormatter.



515
516
517
# File 'lib/kitchen/logger.rb', line 515

def initialize(logger)
  @logger = logger
end

Instance Method Details

#format(line) ⇒ 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.

Routes an already-prefixed stream line to the logger call matching its prefix, stripping the prefix before logging.

Parameters:

  • line (String)

    a single line of prefixed stream output



525
526
527
528
529
530
531
532
533
534
535
# File 'lib/kitchen/logger.rb', line 525

def format(line)
  case line
  when /^-----> / then log_line(:banner, line.gsub(/^[ >-]{6} /, ""))
  when /^D      / then structured_line(:debug, line.gsub(/^D {6}/, ""), line)
  when /^\$\$\$\$\$\$ / then structured_line(:warn, line.gsub(/^\${6} /, ""), line)
  when /^>>>>>> / then log_line(:error, line.gsub(/^[ >-]{6} /, ""))
  when /^!!!!!! / then structured_line(:fatal, line.gsub(/^!{6} /, ""), line)
  when /^       / then log_line(:info, line.gsub(/^[ >-]{6} /, ""))
  else log_line(:info, line)
  end
end