Class: KubernetesDeploy::RemoteLogs
- Inherits:
-
Object
- Object
- KubernetesDeploy::RemoteLogs
- Defined in:
- lib/kubernetes-deploy/remote_logs.rb
Instance Attribute Summary collapse
-
#container_logs ⇒ Object
readonly
Returns the value of attribute container_logs.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(logger:, parent_id:, container_names:, namespace:, context:) ⇒ RemoteLogs
constructor
A new instance of RemoteLogs.
- #print_all(prevent_duplicate: true) ⇒ Object
- #print_latest ⇒ Object
- #sync ⇒ Object
Constructor Details
#initialize(logger:, parent_id:, container_names:, namespace:, context:) ⇒ RemoteLogs
Returns a new instance of RemoteLogs.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/kubernetes-deploy/remote_logs.rb', line 8 def initialize(logger:, parent_id:, container_names:, namespace:, context:) @logger = logger @parent_id = parent_id @container_logs = container_names.map do |n| ContainerLogs.new( logger: logger, container_name: n, parent_id: parent_id, namespace: namespace, context: context ) end end |
Instance Attribute Details
#container_logs ⇒ Object (readonly)
Returns the value of attribute container_logs.
6 7 8 |
# File 'lib/kubernetes-deploy/remote_logs.rb', line 6 def container_logs @container_logs end |
Instance Method Details
#empty? ⇒ Boolean
22 23 24 |
# File 'lib/kubernetes-deploy/remote_logs.rb', line 22 def empty? @container_logs.all?(&:empty?) end |
#print_all(prevent_duplicate: true) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/kubernetes-deploy/remote_logs.rb', line 39 def print_all(prevent_duplicate: true) return if @already_displayed && prevent_duplicate if @container_logs.all?(&:empty?) @logger.warn("No logs found for #{@parent_id}") return end @container_logs.each do |cl| if cl.empty? @logger.warn("No logs found for #{@parent_id} container '#{cl.container_name}'") else @logger.info("Logs from #{@parent_id} container '#{cl.container_name}':") cl.print_all @logger.blank_line end end @already_displayed = true end |
#print_latest ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/kubernetes-deploy/remote_logs.rb', line 30 def print_latest @container_logs.each do |cl| unless cl.printing_started? @logger.info("Streaming logs from #{@parent_id} container '#{cl.container_name}':") end cl.print_latest(prefix: @container_logs.length > 1) end end |
#sync ⇒ Object
26 27 28 |
# File 'lib/kubernetes-deploy/remote_logs.rb', line 26 def sync @container_logs.each(&:sync) end |