Sha256: 4ca8c0d46188abb98e300b974b606346471d7377877c9e155a594c07db287fee

Contents?: true

Size: 1.1 KB

Versions: 34

Compression:

Stored size: 1.1 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 "#{pastel.send(color, prefix)} #{log['data']}"
    end
  end
end

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
krates-1.7.11 lib/kontena/cli/grids/logs_command.rb
krates-1.7.10 lib/kontena/cli/grids/logs_command.rb
krates-1.7.9 lib/kontena/cli/grids/logs_command.rb
krates-1.7.8 lib/kontena/cli/grids/logs_command.rb
krates-1.7.7 lib/kontena/cli/grids/logs_command.rb
krates-1.7.6 lib/kontena/cli/grids/logs_command.rb
krates-1.7.5 lib/kontena/cli/grids/logs_command.rb
krates-1.7.4 lib/kontena/cli/grids/logs_command.rb
krates-1.7.3 lib/kontena/cli/grids/logs_command.rb
krates-1.7.2 lib/kontena/cli/grids/logs_command.rb
krates-1.7.1 lib/kontena/cli/grids/logs_command.rb
krates-1.7.0 lib/kontena/cli/grids/logs_command.rb
krates-1.6.9 lib/kontena/cli/grids/logs_command.rb
krates-1.6.8 lib/kontena/cli/grids/logs_command.rb
krates-1.6.7 lib/kontena/cli/grids/logs_command.rb
krates-1.6.6 lib/kontena/cli/grids/logs_command.rb
krates-1.6.5 lib/kontena/cli/grids/logs_command.rb
krates-1.6.4 lib/kontena/cli/grids/logs_command.rb
krates-1.6.3 lib/kontena/cli/grids/logs_command.rb
krates-1.6.2 lib/kontena/cli/grids/logs_command.rb