From 133c17fa6665256cafdcd1cf76d2ae50233c44f4 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 9 Oct 2006 17:41:36 +0000 Subject: Fixing #305 -- logs now reopen when Puppet restarts, and there is also now an autoflush mechanism available so logs will flush to disk immediately. I also now trap USR2 and reopen logs when it is sent, so if you just want to reopen logs you do not have to restart the whole process. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1750 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet/log.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/puppet') diff --git a/lib/puppet/log.rb b/lib/puppet/log.rb index c8d92e649..c76dd945c 100644 --- a/lib/puppet/log.rb +++ b/lib/puppet/log.rb @@ -237,11 +237,15 @@ module Puppet file = File.open(path, File::WRONLY|File::CREAT|File::APPEND) @file = file + + @autoflush = Puppet[:autoflush] end def handle(msg) @file.puts("%s %s (%s): %s" % [msg.time, msg.source, msg.level, msg.to_s]) + + @file.flush if @autoflush end end @@ -411,6 +415,7 @@ module Puppet # Reopen all of our logs. def Log.reopen + Puppet.notice "Reopening log files" types = @destinations.keys @destinations.each { |type, dest| if dest.respond_to?(:close) -- cgit