diff options
author | John Keiser <john@johnkeiser.com> | 2015-08-31 14:38:50 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-09-01 19:30:43 -0700 |
commit | 25dac92eeb1ffa83ec549bfed0b19672c5847d80 (patch) | |
tree | f5292bfb261d40f1bbe3bdfa2845de87245f78d4 /lib/chef/formatters | |
parent | ad8fd4d65b48519ac154ad9bf9774322b0c6d902 (diff) | |
download | chef-25dac92eeb1ffa83ec549bfed0b19672c5847d80.tar.gz |
Pass deprecations through formatter instead of logs
Diffstat (limited to 'lib/chef/formatters')
-rw-r--r-- | lib/chef/formatters/base.rb | 3 | ||||
-rw-r--r-- | lib/chef/formatters/doc.rb | 36 |
2 files changed, 39 insertions, 0 deletions
diff --git a/lib/chef/formatters/base.rb b/lib/chef/formatters/base.rb index c901068aa0..d3756ef00c 100644 --- a/lib/chef/formatters/base.rb +++ b/lib/chef/formatters/base.rb @@ -212,6 +212,9 @@ class Chef file_load_failed(path, exception) end + def deprecation(message, location=caller(2..2)[0]) + Chef::Log.deprecation("#{message} at #{location}") + end end diff --git a/lib/chef/formatters/doc.rb b/lib/chef/formatters/doc.rb index a5d7e210c5..614cc44e6d 100644 --- a/lib/chef/formatters/doc.rb +++ b/lib/chef/formatters/doc.rb @@ -43,6 +43,26 @@ class Chef def run_completed(node) @end_time = Time.now + # Print out deprecations. + if !deprecations.empty? + puts_line "" + puts_line "Deprecated features used!" + deprecations.each do |message, locations| + if locations.size == 1 + puts_line " #{message} at #{locations.size} location:" + else + puts_line " #{message} at #{locations.size} locations:" + end + locations.each do |location| + prefix = " - " + Array(location).each do |line| + puts_line "#{prefix}#{line}" + prefix = " " + end + end + end + puts_line "" + end if Chef::Config[:why_run] puts_line "Chef Client finished, #{@updated_resources}/#{total_resources} resources would have been updated" else @@ -336,6 +356,16 @@ class Chef end end + def deprecation(message, location=caller(2..2)[0]) + if Chef::Config[:treat_deprecation_warnings_as_errors] + super + end + + # Save deprecations to the screen until the end + deprecations[message] ||= Set.new + deprecations[message] << location + end + def indent indent_by(2) end @@ -343,6 +373,12 @@ class Chef def unindent indent_by(-2) end + + protected + + def deprecations + @deprecations ||= {} + end end end end |