Sha256: 58a7f076a11b44cf0261f12cabb6895f2570397e1b8d8d7e0945ae530f1c5e5c
Contents?: true
Size: 1.89 KB
Versions: 87
Compression:
Stored size: 1.89 KB
Contents
require "cf/cli/app/base" module CF::App class Logs < Base desc "Print out an app's logs" group :apps, :info, :hidden => true input :app, :desc => "Application to get the logs of", :argument => true, :from_given => by_name(:app) input :instance, :desc => "Instance of application to get the logs of", :default => "0" input :all, :desc => "Get logs for every instance", :default => false def logs app = input[:app] instances = if input[:all] || input[:instance] == "all" app.instances else app.instances.select { |i| i.id == input[:instance] } end if instances.empty? if input[:all] fail "No instances found." else fail "Instance #{app.name} \##{input[:instance]} not found." end end spaced(instances) do |i| show_instance_logs(app, i) end end desc "Print out the logs for an app's crashed instances" group :apps, :info, :hidden => true input :app, :desc => "Application to get the logs of", :argument => true, :from_given => by_name(:app) def crashlogs app = input[:app] crashes = app.crashes fail "No crashed instances found." if crashes.empty? most_recent = crashes.sort_by(&:since).last show_instance_logs(app, most_recent) end def show_instance_logs(app, i) return unless i.id logs = with_progress( "Getting logs for #{c(app.name, :name)} " + c("\##{i.id}", :instance)) do i.files("logs") end line unless quiet? spaced(logs) do |log| begin body = with_progress("Reading " + b(log.join("/"))) do |s| i.file(*log) end lines body line unless body.empty? rescue CFoundry::NotFound end end end end end
Version data entries
87 entries across 87 versions & 1 rubygems