Signed-off-by: James Turnbull <[email protected]>
---
 lib/puppet/util/log/destinations.rb |    9 ++++++---
 test/util/log.rb                    |   14 +++++++-------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/lib/puppet/util/log/destinations.rb 
b/lib/puppet/util/log/destinations.rb
index 22b3ded..e56456f 100644
--- a/lib/puppet/util/log/destinations.rb
+++ b/lib/puppet/util/log/destinations.rb
@@ -64,14 +64,17 @@ Puppet::Util::Log.newdesttype :file do
     file = File.open(path, File::WRONLY|File::CREAT|File::APPEND)
 
     @file = file
-
-    @autoflush = Puppet[:autoflush]
   end
 
   def handle(msg)
     @file.puts("#{msg.time} #{msg.source} (#{msg.level}): #{msg}")
 
-    @file.flush if @autoflush
+    @autoflush = Puppet[:autoflush]
+
+    if @autoflush
+      @file.sync = true
+      @file.flush
+    end
   end
 end
 
diff --git a/test/util/log.rb b/test/util/log.rb
index 4dbd3c6..03f57e7 100755
--- a/test/util/log.rb
+++ b/test/util/log.rb
@@ -37,10 +37,10 @@ class TestLog < Test::Unit::TestCase
       assert_nothing_raised {
 
               Puppet::Util::Log.new(
-                
+
           :level => level,
           :source => "Test",
-        
+
           :message => "Unit test for #{level}"
         )
       }
@@ -123,9 +123,9 @@ class TestLog < Test::Unit::TestCase
     assert_nothing_raised {
 
             Puppet::Util::Log.new(
-                
+
         :level => :info,
-        
+
         :message => "A message with %s in it"
       )
     }
@@ -136,9 +136,9 @@ class TestLog < Test::Unit::TestCase
     msg = nil
 
           file = Puppet::Type.type(:file).new(
-                
+
       :path => tempfile,
-        
+
       :check => %w{owner group}
     )
     assert_nothing_raised {
@@ -178,7 +178,7 @@ class TestLog < Test::Unit::TestCase
     Puppet::Util::Log.close(:console)
     Puppet::Util::Log.newdestination(file)
     Puppet.warning "A test"
-    assert(File.read(file) !~ /A test/, "File defualted to autoflush")
+    assert(File.read(file) !~ /A test/, "File defaulted to autoflush")
     Puppet::Util::Log.flush
     assert(File.read(file) =~ /A test/, "File did not flush")
     Puppet::Util::Log.close(file)
-- 
1.7.3.4

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to