summaryrefslogtreecommitdiff
path: root/lib/mixlib/log.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mixlib/log.rb')
-rw-r--r--lib/mixlib/log.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/mixlib/log.rb b/lib/mixlib/log.rb
index 5f216f9..55332e0 100644
--- a/lib/mixlib/log.rb
+++ b/lib/mixlib/log.rb
@@ -29,9 +29,21 @@ module Mixlib
LEVEL_NAMES = LEVELS.invert.freeze
def reset!
+ if @loggers
+ @loggers.each { |l| close(l) }
+ else
+ close(@logger) unless @logger.nil?
+ end
+ ensure
@logger, @loggers = nil, nil
end
+ def close(logger)
+ unless logger.instance_variable_get(:"@logdev").dev == STDOUT
+ logger.close
+ end
+ end
+
# An Array of log devices that will be logged to. Defaults to just the default
# @logger log device, but you can push to this array to add more devices.
def loggers