module Krane::DeferredSummaryLogging
def blank_line(level = :info)
def blank_line(level = :info) public_send(level, "") end
def heading(text, secondary_msg = '', secondary_msg_color = :cyan)
def heading(text, secondary_msg = '', secondary_msg_color = :cyan) padding = (100.0 - (text.length + secondary_msg.length)) / 2 blank_line part1 = ColorizedString.new("#{'-' * padding.floor}#{text}").cyan part2 = ColorizedString.new(secondary_msg).colorize(secondary_msg_color) part3 = ColorizedString.new('-' * padding.ceil).cyan info(part1 + part2 + part3) end
def initialize(*args)
def initialize(*args) reset super end
def phase_heading(phase_name)
def phase_heading(phase_name) @current_phase += 1 heading("Phase #{@current_phase}: #{phase_name}") end
def print_summary(status)
def print_summary(status) status_string = status.to_s.humanize.upcase if status == :success heading("Result: ", status_string, :green) level = :info elsif status == :timed_out heading("Result: ", status_string, :yellow) level = :fatal else heading("Result: ", status_string, :red) level = :fatal end if (actions_sentence = summary.actions_sentence.presence) public_send(level, actions_sentence) blank_line(level) end summary.paragraphs.each do |para| msg_lines = para.split("\n") msg_lines.each { |line| public_send(level, line) } blank_line(level) unless para == summary.paragraphs.last end end
def reset
def reset @summary = DeferredSummary.new @current_phase = 0 end