Sha256: d33cece7b78101511bf76fe793d4626326e80f8b5e67836f05e89ab64388719f

Contents?: true

Size: 1.09 KB

Versions: 103

Compression:

Stored size: 1.09 KB

Contents

require_relative '../helpers/log_helper'

module Kontena::Cli::Grids
  class LogsCommand < Kontena::Command
    include Kontena::Cli::Common
    include Kontena::Cli::Helpers::LogHelper
    option "--node", "NODE", "Filter by node name", multivalued: true
    option "--service", "SERVICE", "Filter by service name", multivalued: true
    option ["-c", "--container"], "CONTAINER", "Filter by container", multivalued: true

    def execute
      require_api_url

      query_params = {}
      query_params[:nodes] = node_list.join(",") unless node_list.empty?
      query_params[:services] = service_list.join(",") unless service_list.empty?
      query_params[:containers] = container_list.join(",") unless container_list.empty?

      show_logs("grids/#{current_grid}/container_logs", query_params) do |log|
        show_log(log)
      end
    end

    def show_log(log)
      color = color_for_container(log['name'])
      if tail?
        prefix = "#{log['name']} |"
      else
        prefix = "#{log['created_at']} #{log['name']}:"
      end

      puts "#{prefix.colorize(color)} #{log['data']}"
    end
  end
end

Version data entries

103 entries across 103 versions & 1 rubygems

Version Path
kontena-cli-1.4.3 lib/kontena/cli/grids/logs_command.rb
kontena-cli-1.4.3.rc1 lib/kontena/cli/grids/logs_command.rb
kontena-cli-1.4.2 lib/kontena/cli/grids/logs_command.rb
kontena-cli-1.4.2.rc1 lib/kontena/cli/grids/logs_command.rb
kontena-cli-1.4.2.pre1 lib/kontena/cli/grids/logs_command.rb
kontena-cli-1.4.1 lib/kontena/cli/grids/logs_command.rb
kontena-cli-1.4.1.rc1 lib/kontena/cli/grids/logs_command.rb
kontena-cli-1.4.1.pre1 lib/kontena/cli/grids/logs_command.rb
kontena-cli-1.3.5 lib/kontena/cli/grids/logs_command.rb
kontena-cli-1.3.5.rc1 lib/kontena/cli/grids/logs_command.rb
kontena-cli-1.4.0 lib/kontena/cli/grids/logs_command.rb
kontena-cli-1.4.0.rc2 lib/kontena/cli/grids/logs_command.rb
kontena-cli-1.4.0.rc1 lib/kontena/cli/grids/logs_command.rb
kontena-cli-1.4.0.pre14 lib/kontena/cli/grids/logs_command.rb
kontena-cli-1.4.0.pre13 lib/kontena/cli/grids/logs_command.rb
kontena-cli-1.4.0.pre12 lib/kontena/cli/grids/logs_command.rb
kontena-cli-1.4.0.pre11 lib/kontena/cli/grids/logs_command.rb
kontena-cli-1.4.0.pre10 lib/kontena/cli/grids/logs_command.rb
kontena-cli-1.4.0.pre9 lib/kontena/cli/grids/logs_command.rb
kontena-cli-1.4.0.pre8 lib/kontena/cli/grids/logs_command.rb