diff options
author | Tim Smith <tsmith@chef.io> | 2017-12-14 20:36:33 -0800 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2017-12-15 08:16:07 -0800 |
commit | 58041e245a34c3773285cd27ff74cea4e838e520 (patch) | |
tree | f9a200a797db880e87ad52cf15d4e0216b3b5a66 /lib/chef/resource/log.rb | |
parent | 1c487ab5977446746f9b389e429707ec8142b063 (diff) | |
download | chef-58041e245a34c3773285cd27ff74cea4e838e520.tar.gz |
Modernize the log resource
General cleanup
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/chef/resource/log.rb')
-rw-r--r-- | lib/chef/resource/log.rb | 65 |
1 files changed, 19 insertions, 46 deletions
diff --git a/lib/chef/resource/log.rb b/lib/chef/resource/log.rb index 8f7879872f..fd6cb3fde9 100644 --- a/lib/chef/resource/log.rb +++ b/lib/chef/resource/log.rb @@ -18,59 +18,32 @@ # require "chef/resource" -require "chef/provider/log" class Chef class Resource + # Sends a string to a log provider. + # Allows logging a :debug, :info, :warn, and :error levels + # Defaults to :info level + # + # @author Cary Penniman <cary@rightscale.com> + # @author Tyler Cloke <tyler@chef.io> + # + # @example logging at default info level + # log "your string to log" + # + # @example logging at specified debug level + # log "a debug string" do + # level :debug + # end + # class Log < Chef::Resource + resource_name :log - identity_attr :message + property :message, String, name_property: true + property :level, Symbol, equal_to: [ :debug, :info, :warn, :error, :fatal ], default: :info + allowed_actions :write default_action :write - - # Sends a string from a recipe to a log provider - # - # log "some string to log" do - # level :info # (default) also supports :warn, :debug, and :error - # end - # - # === Example - # log "your string to log" - # - # or - # - # log "a debug string" { level :debug } - # - - # Initialize log resource with a name as the string to log - # - # === Parameters - # name<String>:: Message to log - # collection<Array>:: Collection of included recipes - # node<Chef::Node>:: Node where resource will be used - def initialize(name, run_context = nil) - super - @level = :info - @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 - def level(arg = nil) - set_or_return( - :level, - arg, - :equal_to => [ :debug, :info, :warn, :error, :fatal ] - ) - end - end end end |