diff options
author | Andy Buecker <andy@tower3.io> | 2014-05-09 15:28:18 -0700 |
---|---|---|
committer | Bryan McLellan <btm@getchef.com> | 2014-06-10 09:05:39 -0700 |
commit | 77119f0f37cc100d450e4f2d2f9dcfb9a57a74a8 (patch) | |
tree | 4adf044b71b2dde3653ee7ddd81cea384bef8fca /lib/chef/provider/log.rb | |
parent | 96a163bf0e5955f983c6b2b9d50f550c17c22876 (diff) | |
download | chef-77119f0f37cc100d450e4f2d2f9dcfb9a57a74a8.tar.gz |
CHEF-4028 - Log resource no longer counts as an updated resource unless a write actually happens
Diffstat (limited to 'lib/chef/provider/log.rb')
-rw-r--r-- | lib/chef/provider/log.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/chef/provider/log.rb b/lib/chef/provider/log.rb index 1c970cc888..a98ad1e1a2 100644 --- a/lib/chef/provider/log.rb +++ b/lib/chef/provider/log.rb @@ -25,6 +25,9 @@ class Chef # Chef log provider, allows logging to chef's logs from recipes class ChefLog < Chef::Provider + # ordered array of the log levels + @@levels = [ :debug, :info, :warn, :error, :fatal ] + # No concept of a 'current' resource for logs, this is a no-op # # === Return @@ -39,7 +42,18 @@ class Chef # true:: Always return true def action_write Chef::Log.send(@new_resource.level, @new_resource.message) - @new_resource.updated_by_last_action(true) + + # resolve the integers for the current log levels + global_level = @@levels.index(Chef::Log.level) + resource_level = @@levels.index(@new_resource.level) + + # If the resource level is greater than or the same os the global + # level, then it should have been written to the log. Mark the + # resource as updated. + if resource_level >= global_level + @new_resource.updated_by_last_action(true) + end + end end |