changeset 5549:f2f42262adbd

hgweb.server: flush log files after every access
author Patrick Mezard <pmezard@gmail.com>
date Tue, 27 Nov 2007 23:55:03 +0100
parents 1fb38ef1f113
children c47484fab02e 8a8c341bd292
files mercurial/hgweb/server.py
diffstat 1 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/server.py	Sun Nov 25 12:17:30 2007 +0100
+++ b/mercurial/hgweb/server.py	Tue Nov 27 23:55:03 2007 +0100
@@ -44,17 +44,17 @@
         self.protocol_version = 'HTTP/1.1'
         BaseHTTPServer.BaseHTTPRequestHandler.__init__(self, *args, **kargs)
 
+    def _log_any(self, fp, format, *args):
+        fp.write("%s - - [%s] %s\n" % (self.client_address[0],
+                                       self.log_date_time_string(),
+                                       format % args))
+        fp.flush()
+
     def log_error(self, format, *args):
-        errorlog = self.server.errorlog
-        errorlog.write("%s - - [%s] %s\n" % (self.client_address[0],
-                                             self.log_date_time_string(),
-                                             format % args))
+        self._log_any(self.server.errorlog, format, *args)
 
     def log_message(self, format, *args):
-        accesslog = self.server.accesslog
-        accesslog.write("%s - - [%s] %s\n" % (self.client_address[0],
-                                              self.log_date_time_string(),
-                                              format % args))
+        self._log_any(self.server.accesslog, format, *args)
 
     def do_write(self):
         try: