Sha256: 5b66e22d94eafc2cb7caefae928e5123a1267eb7672ad582abf2d313c3895dbf

Contents?: true

Size: 1.71 KB

Versions: 3

Compression:

Stored size: 1.71 KB

Contents

class Ey::Core::Cli::Logs < Ey::Core::Cli::Subcommand
  title "logs"
  summary "Retrieve the latest logs for an environment"
  description <<-DESC
    Displays Engine Yard configuration logs for all servers in the environment.  If
    recipes were uploaded to the environment & run, their logs will also be
    displayed beneath the main configuration logs.
  DESC

  option :environment, short: "e", long: "environment", description: "Name or id of the environment to deploy to.", argument: "Environment"
  option :account,     short: 'c', long: 'account',     description: 'Name or ID of the account that the environment resides in.  If no account is specified, the app will deploy to the first environment that meets the criteria, in the accounts you have access to.', argument: 'Account name or id'
  option :server,      short: 's', long: 'server',      description: "Only retrieve logs for the specified server", argument: "id or amazon_id"

  def handle
    operator, environment = core_operator_and_environment_for(options)
    abort "Unable to find matching environment".red unless environment

    servers = if option(:server)
                [environment.servers.get(option(:server))] || environment.servers.all(provisioned_id: option(:server))
              else
                environment.servers.all
              end

    abort "No servers found".red if servers.empty?

    servers.each do |server|
      name = server.name ? "#{server.name} (#{server.role})" : server.role

      if log = server.latest_main_log
        puts "Main logs for #{name}:".green
        puts log.contents
      end

      if log = server.latest_custom_log
        puts "Custom logs for #{name}:".green
        puts log.contents
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ey-core-3.1.2 lib/ey-core/cli/logs.rb
ey-core-3.1.1 lib/ey-core/cli/logs.rb
ey-core-3.1.0 lib/ey-core/cli/logs.rb