summaryrefslogtreecommitdiff
path: root/chef
diff options
context:
space:
mode:
authorMatthew Kent <mkent@magoazul.com>2012-10-24 22:25:59 -0700
committerBryan McLellan <btm@opscode.com>2012-12-14 08:30:41 -0800
commit0c0f9fa8c636a1c65cfb37e5fc20f66c72b91e86 (patch)
tree2b7d4b0ec1997f8c68eb09b01687dcd4a43ad30e /chef
parentb7d92c49a669e8019d63ba4d4595e0675b3b8e4c (diff)
downloadchef-0c0f9fa8c636a1c65cfb37e5fc20f66c72b91e86.tar.gz
CHEF-3006: Add message attrib to log resource to permit typical notifications
Diffstat (limited to 'chef')
-rw-r--r--chef/lib/chef/provider/log.rb2
-rw-r--r--chef/lib/chef/resource/log.rb11
-rw-r--r--chef/spec/unit/resource/log_spec.rb9
3 files changed, 20 insertions, 2 deletions
diff --git a/chef/lib/chef/provider/log.rb b/chef/lib/chef/provider/log.rb
index 5d0417ebda..927ee72fcc 100644
--- a/chef/lib/chef/provider/log.rb
+++ b/chef/lib/chef/provider/log.rb
@@ -38,7 +38,7 @@ class Chef
# === Return
# true:: Always return true
def action_write
- Chef::Log.send(@new_resource.level, @new_resource.name)
+ Chef::Log.send(@new_resource.level, @new_resource.message)
@new_resource.updated_by_last_action(true)
end
diff --git a/chef/lib/chef/resource/log.rb b/chef/lib/chef/resource/log.rb
index d1b6b5af0b..30a5bb93c6 100644
--- a/chef/lib/chef/resource/log.rb
+++ b/chef/lib/chef/resource/log.rb
@@ -20,7 +20,7 @@ class Chef
class Resource
class Log < Chef::Resource
- identity_attr :name
+ identity_attr :message
# Sends a string from a recipe to a log provider
#
@@ -47,6 +47,15 @@ class Chef
@resource_name = :log
@level = :info
@action = :write
+ @message = name
+ end
+
+ def message(arg=nil)
+ set_or_return(
+ :message,
+ arg,
+ :kind_of => String
+ )
end
# <Symbol> Log level, one of :debug, :info, :warn, :error or :fatal
diff --git a/chef/spec/unit/resource/log_spec.rb b/chef/spec/unit/resource/log_spec.rb
index bc5ac13078..4c6b2c122d 100644
--- a/chef/spec/unit/resource/log_spec.rb
+++ b/chef/spec/unit/resource/log_spec.rb
@@ -38,6 +38,15 @@ describe Chef::Resource::Log do
it "should allow you to set a log string" do
@resource.name.should == @log_str
end
+
+ it "should set the message to the first argument to new" do
+ @resource.message.should == @log_str
+ end
+
+ it "should accept a string for the log message" do
+ @resource.message "this is different"
+ @resource.message.should == "this is different"
+ end
it "should accept a vaild level option" do
@resource.level :debug