summaryrefslogtreecommitdiff
path: root/chef
diff options
context:
space:
mode:
authorSeth Chisamore <schisamo@opscode.com>2011-04-21 22:13:00 -0400
committerDaniel DeLeo <dan@opscode.com>2011-04-26 10:05:13 -0700
commit539e64c27dbe11bf8f25d2b191b78ed0be647908 (patch)
treecc666d7d14469c24cbff64b3fb263ef971a1de51 /chef
parent130205bd08b31efac02c1327e6d960e0a2dfd371 (diff)
downloadchef-539e64c27dbe11bf8f25d2b191b78ed0be647908.tar.gz
[CHEF-2256] use Chef::FileCache to write out failed-run-data.json and chef-stacktrace.out
Diffstat (limited to 'chef')
-rw-r--r--chef/lib/chef/application.rb11
-rw-r--r--chef/lib/chef/handler/error_report.rb11
2 files changed, 7 insertions, 15 deletions
diff --git a/chef/lib/chef/application.rb b/chef/lib/chef/application.rb
index 080d06f1fc..c8f3a536fd 100644
--- a/chef/lib/chef/application.rb
+++ b/chef/lib/chef/application.rb
@@ -127,13 +127,12 @@ class Chef::Application
class << self
def debug_stacktrace(e)
message = "#{e.class}: #{e}\n#{e.backtrace.join("\n")}"
- filename = File.join(Chef::Config[:file_cache_path], "chef-stacktrace.out")
- Chef::Log.fatal("Stacktrace dumped to #{filename}")
+ chef_stacktrace_out = "Generated at #{Time.now.to_s}\n"
+ chef_stacktrace_out += message
+
+ Chef::FileCache.store("chef-stacktrace.out", chef_stacktrace_out)
+ Chef::Log.fatal("Stacktrace dumped to #{Chef::FileCache.load("chef-stacktrace.out", false)}")
Chef::Log.debug(message)
- chef_stacktrace_out = File.open(filename, "w")
- chef_stacktrace_out.puts "Generated at #{Time.now.to_s}"
- chef_stacktrace_out.puts message
- chef_stacktrace_out.close
true
end
diff --git a/chef/lib/chef/handler/error_report.rb b/chef/lib/chef/handler/error_report.rb
index eba2d86e65..dc47ed5024 100644
--- a/chef/lib/chef/handler/error_report.rb
+++ b/chef/lib/chef/handler/error_report.rb
@@ -24,15 +24,8 @@ class Chef
class ErrorReport < ::Chef::Handler
def report
- Chef::Log.fatal("Saving node information to #{report_path}")
-
- File.open(report_path, "w") do |file|
- file.puts Chef::JSONCompat.to_json_pretty(data)
- end
- end
-
- def report_path
- File.join(Chef::Config[:file_cache_path], "failed-run-data.json")
+ Chef::FileCache.store("failed-run-data.json", Chef::JSONCompat.to_json_pretty(data))
+ Chef::Log.fatal("Saving node information to #{Chef::FileCache.load("failed-run-data.json", false)}")
end
end