Mercurial > hg > mercurial-crew-with-dirclash
diff mercurial/hgweb.py @ 605:8e82fd763be2
[PATCH] Get "hg serve" to optionally log accesses and errors to files
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[PATCH] Get "hg serve" to optionally log accesses and errors to files
From: Bryan O'Sullivan <bos@serpentine.com>
Get "hg serve" to log accesses and errors to files.
manifest hash: 573ef524d84cc7d2777f5fd982f2ef47f4bcf668
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCyMA5ywK+sNU5EO8RAp1eAJoD6Qqy6XcGInzZKdo0Qp7gLttYzACfRywL
fSGapmCAIaZPoBvoxXTk8Zo=
=ZicU
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Sun, 03 Jul 2005 20:51:05 -0800 |
parents | bc5d058e65e9 |
children | 7369ec5d93f2 |
line wrap: on
line diff
--- 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()