Class: Bosh::Cli::TaskTracking::TaskLogRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/cli/task_tracking/task_log_renderer.rb

Direct Known Subclasses

EventLogRenderer, NullTaskLogRenderer

Constant Summary collapse

EVENT_LOG_STAGES_WITHOUT_PROGRESS_BAR =
[
  'Preparing DNS',
  'Creating bound missing VMs',
  'Binding instance VMs',
  'Updating job',
  'Deleting unneeded instances',
  'Running errand',
  'Deleting instances',
  'Refilling resource pools',
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTaskLogRenderer

Returns a new instance of TaskLogRenderer.



28
29
30
31
32
33
34
35
# File 'lib/cli/task_tracking/task_log_renderer.rb', line 28

def initialize
  @out = Bosh::Cli::Config.output || $stdout
  @out.sync = true
  @lock = Mutex.new
  @output = ''
  @time_adjustment = 0
  @duration = nil
end

Instance Attribute Details

#durationObject

Returns the value of attribute duration.



26
27
28
# File 'lib/cli/task_tracking/task_log_renderer.rb', line 26

def duration
  @duration
end

#time_adjustmentObject

Returns the value of attribute time_adjustment.



25
26
27
# File 'lib/cli/task_tracking/task_log_renderer.rb', line 25

def time_adjustment
  @time_adjustment
end

Class Method Details

.create_for_log_type(log_type) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/cli/task_tracking/task_log_renderer.rb', line 14

def self.create_for_log_type(log_type)
  if log_type == 'event'
    EventLogRenderer.new(stages_without_progress_bar:
      EVENT_LOG_STAGES_WITHOUT_PROGRESS_BAR)
  elsif log_type == 'result' || log_type == 'none'
    NullTaskLogRenderer.new
  else
    TaskLogRenderer.new
  end
end

Instance Method Details

#add_output(output) ⇒ Object



41
42
43
# File 'lib/cli/task_tracking/task_log_renderer.rb', line 41

def add_output(output)
  @output = output
end

#duration_known?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/cli/task_tracking/task_log_renderer.rb', line 37

def duration_known?
  false
end

#finish(state) ⇒ Object



50
51
52
53
# File 'lib/cli/task_tracking/task_log_renderer.rb', line 50

def finish(state)
  refresh
  @done = true
end

#refreshObject



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

def refresh
  @out.print(@output)
  @output = ''
end