Sha256: bd83ff6af0644700adb66cbdd902dc1413ced52dea3f6992434e39b5c37261de
Contents?: true
Size: 1008 Bytes
Versions: 27
Compression:
Stored size: 1008 Bytes
Contents
require_relative 'services_helper' require_relative '../helpers/log_helper' module Kontena::Cli::Services class LogsCommand < Kontena::Command include Kontena::Cli::Common include Kontena::Cli::GridOptions include Kontena::Cli::Helpers::LogHelper include ServicesHelper parameter "NAME", "Service name" option ["-i", "--instance"], "INSTANCE", "Show only given instance specific logs" def execute require_api_url query_params = {} query_params[:container] = parse_container_name(name, instance) if instance show_logs("services/#{parse_service_id(name)}/container_logs", query_params) do |log| show_log(log) end end def show_log(log) color = color_for_container(log['name']) instance_number = log['name'].match(/^.+-(\d+)$/)[1] name = instance_number.nil? ? log['name'] : instance_number prefix = "#{log['created_at']} [#{name}]:".colorize(color) puts "#{prefix} #{log['data']}" end end end
Version data entries
27 entries across 27 versions & 1 rubygems