diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2017-03-01 14:38:31 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2017-04-05 22:35:53 -0700 |
commit | b74d7a53addf42a2be56b262cb1207ffedf48f78 (patch) | |
tree | fc513eaa3b4988ca38892e98e752d9aef2726965 /lib/chef | |
parent | 0537474a7c576011b12149725f65da617b3e1ef0 (diff) | |
download | chef-b74d7a53addf42a2be56b262cb1207ffedf48f78.tar.gz |
CHEF-13: remove magic from the logger/formatter settings
closes #2514
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef')
-rw-r--r-- | lib/chef/application.rb | 31 | ||||
-rw-r--r-- | lib/chef/client.rb | 2 |
2 files changed, 5 insertions, 28 deletions
diff --git a/lib/chef/application.rb b/lib/chef/application.rb index eba0d48e57..005418d184 100644 --- a/lib/chef/application.rb +++ b/lib/chef/application.rb @@ -144,22 +144,12 @@ class Chef # unattended, the `force_formatter` option is provided. # # === Auto Log Level - # When `log_level` is set to `:auto` (default), the log level will be `:warn` - # when the primary output mode is an output formatter (see - # +using_output_formatter?+) and `:info` otherwise. + # The `log_level` of `:auto` means `:warn` in the formatter and `:info` in + # the logger. # - # === Automatic STDOUT Logging - # When `force_logger` is configured (e.g., Chef 10 mode), a second logger - # with output on STDOUT is added when running in a console (STDOUT is a tty) - # and the configured log_location isn't STDOUT. This accounts for the case - # that a user has configured a log_location in client.rb, but is running - # chef-client by hand to troubleshoot a problem. def configure_logging configure_log_location Chef::Log.init(MonoLogger.new(Chef::Config[:log_location])) - if want_additional_logger? - configure_stdout_logger - end Chef::Log.level = resolve_log_level rescue StandardError => error Chef::Log.fatal("Failed to open or create log file at #{Chef::Config[:log_location]}: #{error.class} (#{error.message})") @@ -180,22 +170,9 @@ class Chef end end - def configure_stdout_logger - stdout_logger = MonoLogger.new(STDOUT) - stdout_logger.formatter = Chef::Log.logger.formatter - Chef::Log.loggers << stdout_logger - end - - # Based on config and whether or not STDOUT is a tty, should we setup a - # secondary logger for stdout? - def want_additional_logger? - ( Chef::Config[:log_location] != STDOUT ) && STDOUT.tty? && (!Chef::Config[:daemonize]) && (Chef::Config[:force_logger]) - end - - # Use of output formatters is assumed if `force_formatter` is set or if - # `force_logger` is not set and STDOUT is to a console (tty) + # 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] && STDOUT.tty?) + Chef::Config[:force_formatter] || !Chef::Config[:force_logger] end def auto_log_level? diff --git a/lib/chef/client.rb b/lib/chef/client.rb index b219fdfdd6..c3eaa02bed 100644 --- a/lib/chef/client.rb +++ b/lib/chef/client.rb @@ -372,7 +372,7 @@ class Chef # @api private def default_formatter - if (STDOUT.tty? && !Chef::Config[:force_logger]) || Chef::Config[:force_formatter] + if !Chef::Config[:force_logger] || Chef::Config[:force_formatter] [:doc] else [:null] |