summaryrefslogtreecommitdiff
path: root/lib/chef/application.rb
diff options
context:
space:
mode:
authorNikhil Benesch <nikhil.benesch@gmail.com>2014-01-13 00:00:31 -0500
committerdanielsdeleo <dan@opscode.com>2014-01-20 16:58:41 -0800
commit6a4b9a7849f4c60fdd2b016b288e01f2a6fd03f2 (patch)
tree3bab09fd5bd64cfc24f0f3573dbe54fef2f41bc5 /lib/chef/application.rb
parente15f04b1ed124767a04ef4f5de4f8678fcbe33df (diff)
downloadchef-6a4b9a7849f4c60fdd2b016b288e01f2a6fd03f2.tar.gz
CHEF-4725: Validate 'log_location' setting on log initialization
Previously, a Mixlib::Config setter method verified that 'log_location' was set to a writeable file or a valid IO stream. Due to the way Mixlib::Config handles `default` and `merge!`, this setter method would not fire if the 'log_location' was left unconfigured or if it was set on the command line, resulting in inconsistent error handling. This commit moves the validation logic out of the configuration layer and into the log initializion layer. This ensures that error handling is consistent, regardless of where the 'log_location' setting is configured. Validation logic is also simplified, relying on the MonoLogger class to open and configure any necessary IO streams.
Diffstat (limited to 'lib/chef/application.rb')
-rw-r--r--lib/chef/application.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/chef/application.rb b/lib/chef/application.rb
index 98bdedff7f..4e6b29cec6 100644
--- a/lib/chef/application.rb
+++ b/lib/chef/application.rb
@@ -118,6 +118,9 @@ class Chef::Application
configure_stdout_logger
end
Chef::Log.level = resolve_log_level
+ rescue => error
+ Chef::Log.fatal("Failed to open or create log file at #{Chef::Config[:log_location]}: #{error.class} (#{error.message})")
+ Chef::Application.fatal!("Aborting due to invalid 'log_location' configuration", 2)
end
def configure_stdout_logger