Permalink
Browse files

find log files dynamically rather than guessing

Change-Id: I7dd07da7246d9872eb44c17c8d6ed2232be6b94c
  • Loading branch information...
1 parent b98fbaa commit 235c77385e32fa7788c8d1d7daa72d4993ca51f6 @vito vito committed Feb 8, 2012
Showing with 18 additions and 19 deletions.
  1. +18 −19 lib/cli/commands/apps.rb
View
@@ -193,7 +193,7 @@ def files(appname, path='/')
instance = @options[:instance] || '0'
content = client.app_files(appname, path, instance)
display content
- rescue VMC::Client::TargetError
+ rescue VMC::Client::NotFound, VMC::Client::TargetError
err 'No such file or directory'
end
@@ -675,10 +675,6 @@ def display_logfile(path, content, instance='0', banner=nil)
end
end
- def log_file_paths
- %w[logs/stderr.log logs/stdout.log logs/startup.log]
- end
-
def grab_all_logs(appname)
instances_info_envelope = client.app_instances(appname)
return if instances_info_envelope.is_a?(Array)
@@ -689,15 +685,23 @@ def grab_all_logs(appname)
end
def grab_logs(appname, instance)
- log_file_paths.each do |path|
+ files_under(appname, instance, "/logs").each do |path|
begin
content = client.app_files(appname, path, instance)
display_logfile(path, content, instance)
- rescue VMC::Client::TargetError
+ rescue VMC::Client::NotFound, VMC::Client::TargetError
end
end
end
+ def files_under(appname, instance, path)
+ client.app_files(appname, path, instance).split("\n").collect do |l|
+ "#{path}/#{l.split[0]}"
+ end
+ rescue VMC::Client::NotFound, VMC::Client::TargetError
+ []
+ end
+
def grab_crash_logs(appname, instance, was_staged=false)
# stage crash info
crashes(appname, false) unless was_staged
@@ -706,16 +710,11 @@ def grab_crash_logs(appname, instance, was_staged=false)
map = VMC::Cli::Config.instances
instance = map[instance] if map[instance]
- %w{
- /logs/err.log /logs/staging.log /logs/migration.log
- /app/logs/stderr.log /app/logs/stdout.log /app/logs/startup.log
- /app/logs/migration.log
- }.each do |path|
- begin
- content = client.app_files(appname, path, instance)
- display_logfile(path, content, instance)
- rescue VMC::Client::TargetError
- end
+ (files_under(appname, instance, "/logs") +
+ files_under(appname, instance, "/app/logs") +
+ files_under(appname, instance, "/app/log")).each do |path|
+ content = client.app_files(appname, path, instance)
+ display_logfile(path, content, instance)
end
end
@@ -732,7 +731,7 @@ def grab_startup_tail(appname, since = 0)
display tail.join("\n") if new_lines > 0
end
since + new_lines
- rescue VMC::Client::TargetError
+ rescue VMC::Client::NotFound, VMC::Client::TargetError
0
end
@@ -1064,7 +1063,7 @@ def all_files(appname, path)
entry[:index],
"====> [#{entry[:index]}: #{path}] <====\n".bold
)
- rescue VMC::Client::TargetError
+ rescue VMC::Client::NotFound, VMC::Client::TargetError
end
end
end

0 comments on commit 235c773

Please sign in to comment.