mercurial/hgweb.py
changeset 605 8e82fd763be2
parent 603 bc5d058e65e9
child 620 7369ec5d93f2
--- a/mercurial/hgweb.py
+++ b/mercurial/hgweb.py
@@ -694,12 +694,22 @@ class hgweb:
         else:
             write(self.t("error"))
 
-def create_server(path, name, templates, address, port):
+def create_server(path, name, templates, address, port,
+                  accesslog = sys.stdout, errorlog = sys.stderr):
 
     import BaseHTTPServer
-    import sys, os
 
     class hgwebhandler(BaseHTTPServer.BaseHTTPRequestHandler):
+        def log_error(self, format, *args):
+            errorlog.write("%s - - [%s] %s\n" % (self.address_string(),
+                                                 self.log_date_time_string(),
+                                                 format % args))
+            
+        def log_message(self, format, *args):
+            accesslog.write("%s - - [%s] %s\n" % (self.address_string(),
+                                                  self.log_date_time_string(),
+                                                  format % args))
+
         def do_POST(self):
             try:
                 self.do_hgweb()
@@ -761,6 +771,8 @@ def create_server(path, name, templates,
     hg = hgweb(path, name, templates)
     return BaseHTTPServer.HTTPServer((address, port), hgwebhandler)
 
-def server(path, name, templates, address, port):
-    httpd = create_server(path, name, templates, address, port)
+def server(path, name, templates, address, port,
+           accesslog = sys.stdout, errorlog = sys.stderr):
+    httpd = create_server(path, name, templates, address, port,
+                          accesslog, errorlog)
     httpd.serve_forever()