Mercurial > public > mercurial-scm > hg
diff mercurial/commands.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 | 40a66d464ac2 |
children | 94744f6fe0e7 |
line wrap: on
line diff
--- a/mercurial/commands.py Sun Jul 03 20:49:48 2005 -0800 +++ b/mercurial/commands.py Sun Jul 03 20:51:05 2005 -0800 @@ -794,8 +794,13 @@ def serve(ui, repo, **opts): """export the repository via HTTP""" + def openlog(opt, default): + if opts[opt] and opts[opt] != '-': return open(opts[opt], 'w') + else: return default httpd = hgweb.create_server(repo.root, opts["name"], opts["templates"], - opts["address"], opts["port"]) + opts["address"], opts["port"], + openlog('accesslog', sys.stdout), + openlog('errorlog', sys.stderr)) if ui.verbose: addr, port = httpd.socket.getsockname() if addr == '0.0.0.0': @@ -805,9 +810,9 @@ addr = socket.gethostbyaddr(addr)[0] except: pass if port != 80: - ui.status('listening on http://%s:%d/\n' % (addr, port)) + ui.status('listening at http://%s:%d/\n' % (addr, port)) else: - ui.status('listening on http://%s/\n' % addr) + ui.status('listening at http://%s/\n' % addr) httpd.serve_forever() def status(ui, repo): @@ -973,10 +978,12 @@ ("r", "rev", "", "revision")], "hg revert [files|dirs]"), "root": (root, [], "hg root"), - "^serve": (serve, [('p', 'port', 8000, 'listen port'), - ('a', 'address', '', 'interface address'), - ('n', 'name', os.getcwd(), 'repository name'), - ('t', 'templates', "", 'template map')], + "^serve": (serve, [('A', 'accesslog', '', 'access log file'), + ('E', 'errorlog', '', 'error log file'), + ('p', 'port', 8000, 'listen port'), + ('a', 'address', '', 'interface address'), + ('n', 'name', os.getcwd(), 'repository name'), + ('t', 'templates', "", 'template map')], "hg serve [options]"), "^status": (status, [], 'hg status'), "tag": (tag, [('t', 'text', "", 'commit text'),