diff --git a/libpathod/pathod.py b/libpathod/pathod.py index b1343ea2e..0ae32c47b 100644 --- a/libpathod/pathod.py +++ b/libpathod/pathod.py @@ -81,18 +81,22 @@ class PathodHandler(tcp.BaseHandler): for i in self.server.anchors: if i[0].match(path): + self.info("Serving anchor: %s"%path) return self.serve_crafted(i[1], request_log) if not self.server.nocraft and path.startswith(self.server.craftanchor): spec = urllib.unquote(path)[len(self.server.craftanchor):] + self.info("Serving spec: %s"%spec) try: crafted = rparse.parse_response(self.server.request_settings, spec) except rparse.ParseException, v: + self.info("Parse error: %s"%v.msg) crafted = rparse.PathodErrorResponse( "Parse Error", "Error parsing response spec: %s\n"%v.msg + v.marked() ) except rparse.FileAccessDenied: + self.info("File access denied") crafted = rparse.PathodErrorResponse("Access Denied") return self.serve_crafted(crafted, request_log) elif self.server.noweb: @@ -100,6 +104,7 @@ class PathodHandler(tcp.BaseHandler): crafted.serve(self.wfile, self.server.check_policy) return False else: + self.info("app: %s %s"%(method, path)) cc = wsgi.ClientConn(self.client_address) req = wsgi.Request(cc, "http", method, path, headers, content) sn = self.connection.getsockname() @@ -110,7 +115,6 @@ class PathodHandler(tcp.BaseHandler): version.NAMEVERSION ) app.serve(req, self.wfile) - self.debug("%s %s"%(method, path)) return True def handle(self): diff --git a/pathod b/pathod index 56f6e3fe0..144e01b53 100755 --- a/pathod +++ b/pathod @@ -1,5 +1,5 @@ #!/usr/bin/env python -import argparse, sys, logging +import argparse, sys, logging, logging.handlers from libpathod import pathod, utils, version if __name__ == "__main__": @@ -18,6 +18,10 @@ if __name__ == "__main__": "-d", dest='staticdir', default=None, type=str, help='Directory for static files.' ) + parser.add_argument( + "-f", dest='logfile', default=None, type=str, + help='Log file.' + ) parser.add_argument( "--debug", dest='debug', default=False, action="store_true", help='Enable debug output.' @@ -86,6 +90,10 @@ if __name__ == "__main__": ) if not args.debug: logging.disable(logging.DEBUG) + if args.logfile: + ch = logging.handlers.WatchedFileHandler(args.logfile) + root.addHandler(ch) + sizelimit = None if args.sizelimit: @@ -104,7 +112,7 @@ if __name__ == "__main__": sizelimit = sizelimit, noweb = args.noweb, nocraft = args.nocraft, - noapi = args.noapi, + noapi = args.noapi, nohang = args.nohang ) except pathod.PathodError, v: