Sha256: 07d4965bf8614fa7fb878aa17511010783cede33e11866c72cd5c5a35d334673
Contents?: true
Size: 1.49 KB
Versions: 12
Compression:
Stored size: 1.49 KB
Contents
# frozen_string_literal: true require 'kubernetes-deploy/container_logs' module KubernetesDeploy class RemoteLogs attr_reader :container_logs 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 def empty? @container_logs.all?(&:empty?) end def sync @container_logs.each(&:sync) end 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 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 end end
Version data entries
12 entries across 12 versions & 1 rubygems