From 68d75f2d22a4a0f7c39d2eed0de6fb802a82941d Mon Sep 17 00:00:00 2001 From: Thom May Date: Wed, 11 Nov 2015 09:09:01 +0000 Subject: More code review --- lib/chef/event_dispatch/dispatcher.rb | 5 +---- lib/chef/provider/execute.rb | 8 ++------ 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/chef/event_dispatch/dispatcher.rb b/lib/chef/event_dispatch/dispatcher.rb index 7d7d2c0ad4..ad7df46cd0 100644 --- a/lib/chef/event_dispatch/dispatcher.rb +++ b/lib/chef/event_dispatch/dispatcher.rb @@ -22,10 +22,7 @@ class Chef # Check to see if we are dispatching to a formatter def formatter? - @subscribers.each do |s| - return s.is_formatter? if s.respond_to?(:is_formatter?) - end - false + @subscribers.any? { |s| s.respond_to?(:is_formatter?) && s.is_formatter? } end #### diff --git a/lib/chef/provider/execute.rb b/lib/chef/provider/execute.rb index 16de268258..200beb02ad 100644 --- a/lib/chef/provider/execute.rb +++ b/lib/chef/provider/execute.rb @@ -79,11 +79,7 @@ class Chef end def live_stream? - !!new_resource.live_stream - end - - def stream_to_formatter? - Chef::Config[:stream_execute_output] && run_context.events.formatter? + Chef::Config[:stream_execute_output] || !!new_resource.live_stream end def stream_to_stdout? @@ -102,7 +98,7 @@ class Chef opts[:log_level] = :info opts[:log_tag] = new_resource.to_s if (Chef::Log.info? || live_stream?) && !sensitive? - if stream_to_formatter? + if run_context.events.formatter? opts[:live_stream] = Chef::EventDispatch::EventsOutputStream.new(run_context.events, :name => :execute) elsif stream_to_stdout? opts[:live_stream] = STDOUT -- cgit v1.2.1