summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel DeLeo <dan@opscode.com>2011-03-15 19:31:49 -0700
committerDaniel DeLeo <dan@opscode.com>2011-03-15 19:31:49 -0700
commitdc1c69935b1516e8f9bc7dd7c25dc234ba8e5740 (patch)
treee39d9a5033507b00cfa614733acb8ccbcb2d255f /lib
parent9939a40e1cbbf509244a62c05b9089f69af1b2bb (diff)
downloadmixlib-log-dc1c69935b1516e8f9bc7dd7c25dc234ba8e5740.tar.gz
Add input checking when bulk assigning log devices
Diffstat (limited to 'lib')
-rw-r--r--lib/mixlib/log.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/mixlib/log.rb b/lib/mixlib/log.rb
index 1ada401..979c9d2 100644
--- a/lib/mixlib/log.rb
+++ b/lib/mixlib/log.rb
@@ -51,10 +51,16 @@ module Mixlib
end
def use_log_devices(other)
- if other.respond_to?(:loggers)
+ if other.respond_to?(:loggers) && other.respond_to?(:logger)
@loggers = other.loggers
- else
+ @logger = other.logger
+ elsif other.kind_of?(Array)
@loggers = other
+ @logger = other.first
+ else
+ msg = "#use_log_devices takes a Mixlib::Log object or array of log devices. " <<
+ "You gave: #{other.inspect}"
+ raise ArgumentError, msg
end
end