Mercurial > public > mercurial-scm > hg-stable
comparison 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 |
comparison
equal
deleted
inserted
replaced
604:40a66d464ac2 | 605:8e82fd763be2 |
---|---|
692 sys.stdout.write(z.flush()) | 692 sys.stdout.write(z.flush()) |
693 | 693 |
694 else: | 694 else: |
695 write(self.t("error")) | 695 write(self.t("error")) |
696 | 696 |
697 def create_server(path, name, templates, address, port): | 697 def create_server(path, name, templates, address, port, |
698 accesslog = sys.stdout, errorlog = sys.stderr): | |
698 | 699 |
699 import BaseHTTPServer | 700 import BaseHTTPServer |
700 import sys, os | |
701 | 701 |
702 class hgwebhandler(BaseHTTPServer.BaseHTTPRequestHandler): | 702 class hgwebhandler(BaseHTTPServer.BaseHTTPRequestHandler): |
703 def log_error(self, format, *args): | |
704 errorlog.write("%s - - [%s] %s\n" % (self.address_string(), | |
705 self.log_date_time_string(), | |
706 format % args)) | |
707 | |
708 def log_message(self, format, *args): | |
709 accesslog.write("%s - - [%s] %s\n" % (self.address_string(), | |
710 self.log_date_time_string(), | |
711 format % args)) | |
712 | |
703 def do_POST(self): | 713 def do_POST(self): |
704 try: | 714 try: |
705 self.do_hgweb() | 715 self.do_hgweb() |
706 except socket.error, inst: | 716 except socket.error, inst: |
707 if inst.args[0] != 32: raise | 717 if inst.args[0] != 32: raise |
759 sys.argv, sys.stdin, sys.stdout, sys.stderr = save | 769 sys.argv, sys.stdin, sys.stdout, sys.stderr = save |
760 | 770 |
761 hg = hgweb(path, name, templates) | 771 hg = hgweb(path, name, templates) |
762 return BaseHTTPServer.HTTPServer((address, port), hgwebhandler) | 772 return BaseHTTPServer.HTTPServer((address, port), hgwebhandler) |
763 | 773 |
764 def server(path, name, templates, address, port): | 774 def server(path, name, templates, address, port, |
765 httpd = create_server(path, name, templates, address, port) | 775 accesslog = sys.stdout, errorlog = sys.stderr): |
776 httpd = create_server(path, name, templates, address, port, | |
777 accesslog, errorlog) | |
766 httpd.serve_forever() | 778 httpd.serve_forever() |