diff options
author | Thom May <thom@chef.io> | 2015-11-09 14:59:01 +0000 |
---|---|---|
committer | Thom May <thom@chef.io> | 2015-11-09 15:04:04 +0000 |
commit | db8cda192518f7d3658573cb7974eb8a6e3dd6d1 (patch) | |
tree | 73ee6f11c120e0f15c7c2be1fd311725f9ad40b6 /lib/chef | |
parent | 28487132e3d5469c07cbe790fb46edfd555d1c12 (diff) | |
download | chef-db8cda192518f7d3658573cb7974eb8a6e3dd6d1.tar.gz |
respond to review comments
the logic is now:
if the resource is not sensitive, and if it's explicitly requested to be
streamed or if the log level is info or debug, then we'll consider
streaming it.
If we're configured to send the output to the events stream, we'll do
so.
Otherwise, if we're not daemonized and have a TTY, we'll go to STDOUT
Diffstat (limited to 'lib/chef')
-rw-r--r-- | lib/chef/provider/execute.rb | 10 | ||||
-rw-r--r-- | lib/chef/resource/execute.rb | 8 |
2 files changed, 15 insertions, 3 deletions
diff --git a/lib/chef/provider/execute.rb b/lib/chef/provider/execute.rb index 494267828f..16de268258 100644 --- a/lib/chef/provider/execute.rb +++ b/lib/chef/provider/execute.rb @@ -78,12 +78,16 @@ class Chef !!new_resource.sensitive end + def live_stream? + !!new_resource.live_stream + end + def stream_to_formatter? - Chef::Config[:always_stream_execute] || run_context.events.formatter? + Chef::Config[:stream_execute_output] && run_context.events.formatter? end def stream_to_stdout? - STDOUT.tty? && !Chef::Config[:daemon] && Chef::Log.info? + STDOUT.tty? && !Chef::Config[:daemon] end def opts @@ -97,7 +101,7 @@ class Chef opts[:umask] = umask if umask opts[:log_level] = :info opts[:log_tag] = new_resource.to_s - unless sensitive? + if (Chef::Log.info? || live_stream?) && !sensitive? if stream_to_formatter? opts[:live_stream] = Chef::EventDispatch::EventsOutputStream.new(run_context.events, :name => :execute) elsif stream_to_stdout? diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb index 11c4ae045c..4f92a7ad35 100644 --- a/lib/chef/resource/execute.rb +++ b/lib/chef/resource/execute.rb @@ -49,6 +49,7 @@ class Chef @umask = nil @default_guard_interpreter = :execute @is_guard_interpreter = false + @live_stream = false end def umask(arg=nil) @@ -101,6 +102,13 @@ class Chef ) end + def live_stream(arg=nil) + set_or_return( + :live_stream, + arg, + :kind_of => [ TrueClass, FalseClass ]) + end + def path(arg=nil) Chef::Log.warn "The 'path' attribute of 'execute' is not used by any provider in Chef 11 or Chef 12. Use 'environment' attribute to configure 'PATH'. This attribute will be removed in Chef 13." |