diff options
author | Lamont Granquist <lamont@chef.io> | 2020-07-02 07:58:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-02 07:58:09 -0700 |
commit | 09db58acb1df121c5661a8dd672219d8f0ddbd03 (patch) | |
tree | 95c9297fefa84a7a439dcbb53e19e289c3d16e23 | |
parent | 93cb2accdb53a48981527c576d44604ffaee8f64 (diff) | |
parent | 45ac1b8db4b04e45e6a90f87d00d333e29ac9f03 (diff) | |
download | chef-09db58acb1df121c5661a8dd672219d8f0ddbd03.tar.gz |
Merge pull request #10097 from chef/lcg/fix-syslog
-rw-r--r-- | lib/chef/application.rb | 12 | ||||
-rw-r--r-- | lib/chef/client.rb | 2 | ||||
-rwxr-xr-x | spec/functional/resource/aix_service_spec.rb | 1 |
3 files changed, 13 insertions, 2 deletions
diff --git a/lib/chef/application.rb b/lib/chef/application.rb index 0d80123bda..1e3b72e1ad 100644 --- a/lib/chef/application.rb +++ b/lib/chef/application.rb @@ -194,8 +194,10 @@ class Chef chef_config[:log_location].map! do |log_location| case log_location when :syslog, "syslog" + force_force_logger logger::Syslog.new when :win_evt, "win_evt" + force_force_logger logger::WinEvt.new else # should be a path or STDOUT @@ -204,6 +206,16 @@ class Chef end end + # Force the logger by default for the :winevt and :syslog loggers. Since we do not and cannot + # support multiple log levels in a mix-and-match situation with formatters and loggers, and the + # formatters do not support syslog, we force the formatter off by default and the log level is + # thus info by default. Users can add `--force-formatter -l info` to get back formatter output + # on STDOUT along with syslog logging. + # + def force_force_logger + chef_config[:force_logger] = true unless chef_config[:force_formatter] + end + # Use of output formatters is assumed if `force_formatter` is set or if `force_logger` is not set def using_output_formatter? chef_config[:force_formatter] || !chef_config[:force_logger] diff --git a/lib/chef/client.rb b/lib/chef/client.rb index a43740258d..b6f9958d64 100644 --- a/lib/chef/client.rb +++ b/lib/chef/client.rb @@ -343,7 +343,7 @@ class Chef formatters_for_run.map do |formatter_name, output_path| if output_path.nil? Chef::Formatters.new(formatter_name, STDOUT_FD, STDERR_FD) - else + elsif output_path.is_a?(String) io = File.open(output_path, "a+") io.sync = true Chef::Formatters.new(formatter_name, io, io) diff --git a/spec/functional/resource/aix_service_spec.rb b/spec/functional/resource/aix_service_spec.rb index 78064f8abc..e7e6d0e822 100755 --- a/spec/functional/resource/aix_service_spec.rb +++ b/spec/functional/resource/aix_service_spec.rb @@ -88,7 +88,6 @@ describe Chef::Resource::Service, :requires_root, :aix_only do Chef::RunContext.new(node, {}, events) end - describe "When service is a subsystem" do before(:all) do script_dir = File.join(File.dirname(__FILE__), "/../assets/") |