summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-01-31 10:29:48 -0700
committerLuke Kanies <luke@madstop.com>2009-02-06 18:08:43 -0600
commit8dc0005473ad2b0785919e0bd79ac7d60342625d (patch)
treea401b905ca2858920dbc55c19368d8c67934cea6
parent37d1a7cf2c637e2bde16623007014125066fcec5 (diff)
downloadpuppet-8dc0005473ad2b0785919e0bd79ac7d60342625d.tar.gz
puppet-8dc0005473ad2b0785919e0bd79ac7d60342625d.tar.xz
puppet-8dc0005473ad2b0785919e0bd79ac7d60342625d.zip
Adding a 'close_all' method to the Log class.
This moves the code out of Daemon. Signed-off-by: Luke Kanies <luke@madstop.com>
-rw-r--r--lib/puppet/util/log.rb7
-rwxr-xr-xspec/unit/util/log.rb8
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb
index b57faad42..a74432021 100644
--- a/lib/puppet/util/log.rb
+++ b/lib/puppet/util/log.rb
@@ -104,6 +104,13 @@ class Puppet::Util::Log
end
end
+ def self.close_all
+ # And close all logs except the console.
+ destinations.each do |dest|
+ close(dest)
+ end
+ end
+
# Flush any log destinations that support such operations.
def Log.flush
@destinations.each { |type, dest|
diff --git a/spec/unit/util/log.rb b/spec/unit/util/log.rb
index c42b25c74..b996f17a0 100755
--- a/spec/unit/util/log.rb
+++ b/spec/unit/util/log.rb
@@ -5,6 +5,14 @@ Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f
require 'puppet/util/log'
describe Puppet::Util::Log do
+ it "should be able to close all log destinations" do
+ Puppet::Util::Log.expects(:destinations).returns %w{foo bar}
+ Puppet::Util::Log.expects(:close).with("foo")
+ Puppet::Util::Log.expects(:close).with("bar")
+
+ Puppet::Util::Log.close_all
+ end
+
describe "instances" do
before do
Puppet::Util::Log.stubs(:newmessage)