Class: Bolt::Outputter::Logger
Instance Method Summary
collapse
for_format, #indent, #print_error, #print_message, #spin, #start_spin, #stop_spin
Constructor Details
#initialize(verbose, trace) ⇒ Logger
Returns a new instance of Logger.
8
9
10
11
|
# File 'lib/bolt/outputter/logger.rb', line 8
def initialize(verbose, trace)
super(false, verbose, trace, false)
@logger = Bolt::Logger.logger(self)
end
|
Instance Method Details
#handle_event(event) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/bolt/outputter/logger.rb', line 13
def handle_event(event)
case event[:type]
when :step_start
log_step_start(**event)
when :step_finish
log_step_finish(**event)
when :plan_start
log_plan_start(event)
when :plan_finish
log_plan_finish(event)
when :container_start
log_container_start(event)
when :container_finish
log_container_finish(event)
when :log, :message, :verbose
log_message(**event)
end
end
|
#log_container_finish(event) ⇒ Object
62
63
64
65
66
67
68
69
|
# File 'lib/bolt/outputter/logger.rb', line 62
def log_container_finish(event)
result = event[:result]
if result.success?
@logger.info("Finished: run container '#{result.object}' succeeded.")
else
@logger.info("Finished: run container '#{result.object}' failed.")
end
end
|
#log_container_start(event) ⇒ Object
58
59
60
|
# File 'lib/bolt/outputter/logger.rb', line 58
def log_container_start(event)
@logger.info("Starting: run container '#{event[:image]}'")
end
|
#log_message(level:, message:, **_kwargs) ⇒ Object
71
72
73
|
# File 'lib/bolt/outputter/logger.rb', line 71
def log_message(level:, message:, **_kwargs)
@logger.send(level, message)
end
|
#log_plan_finish(event) ⇒ Object
52
53
54
55
56
|
# File 'lib/bolt/outputter/logger.rb', line 52
def log_plan_finish(event)
plan = event[:plan]
duration = event[:duration]
@logger.info("Finished: plan #{plan} in #{duration.round(2)} sec")
end
|
#log_plan_start(event) ⇒ Object
47
48
49
50
|
# File 'lib/bolt/outputter/logger.rb', line 47
def log_plan_start(event)
plan = event[:plan]
@logger.info("Starting: plan #{plan}")
end
|
#log_step_finish(description:, result:, duration:, **_kwargs) ⇒ Object
41
42
43
44
45
|
# File 'lib/bolt/outputter/logger.rb', line 41
def log_step_finish(description:, result:, duration:, **_kwargs)
failures = result.error_set.length
plural = failures == 1 ? '' : 's'
@logger.info("Finished: #{description} with #{failures} failure#{plural} in #{duration.round(2)} sec")
end
|
#log_step_start(description:, targets:, **_kwargs) ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/bolt/outputter/logger.rb', line 32
def log_step_start(description:, targets:, **_kwargs)
target_str = if targets.length > 5
"#{targets.count} targets"
else
targets.map(&:safe_name).join(', ')
end
@logger.info("Starting: #{description} on #{target_str}")
end
|