Class: Bosh::Cli::TaskTracking::EventLogRenderer

Inherits:
TaskLogRenderer show all
Extended by:
Forwardable
Defined in:
lib/cli/task_tracking/event_log_renderer.rb

Defined Under Namespace

Classes: InvalidEvent

Instance Attribute Summary

Attributes inherited from TaskLogRenderer

#duration, #time_adjustment

Instance Method Summary collapse

Methods inherited from TaskLogRenderer

create_for_log_type, #duration_known?, #refresh

Constructor Details

#initializeEventLogRenderer

Returns a new instance of EventLogRenderer.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cli/task_tracking/event_log_renderer.rb', line 11

def initialize
  super

  @printer = SmartWhitespacePrinter.new
  @total_duration = TotalDuration.new

  presenter = StageCollectionPresenter.new(@printer)

  @stage_collection = StageCollection.new(
    stage_started:  presenter.method(:start_stage),
    stage_finished: presenter.method(:finish_stage),
    stage_failed:   presenter.method(:fail_stage),

    task_started:   presenter.method(:start_task),
    task_finished:  presenter.method(:finish_task),
    task_failed:    presenter.method(:fail_task),
  )
end

Instance Method Details

#add_output(output) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/cli/task_tracking/event_log_renderer.rb', line 32

def add_output(output)
  output.to_s.split("\n").each do |line|
    begin
      event = parse_event(line)
      add_event(event) if event
    rescue InvalidEvent => e
      @printer.print(:line_around, "Received invalid event: #{e.message}".make_red)
    end
  end

  add_raw_output(@printer.output)
end

#add_raw_outputObject



30
# File 'lib/cli/task_tracking/event_log_renderer.rb', line 30

alias_method :add_raw_output, :add_output

#finish(state) ⇒ Object



45
46
47
48
49
# File 'lib/cli/task_tracking/event_log_renderer.rb', line 45

def finish(state)
  @printer.finish
  add_raw_output(@printer.output)
  super
end