diff --git a/libpathod/pathoc.py b/libpathod/pathoc.py index 5ad1bd261..e378e8632 100644 --- a/libpathod/pathoc.py +++ b/libpathod/pathoc.py @@ -1,7 +1,6 @@ from netlib import tcp, http import rparse - class PathocError(Exception): pass diff --git a/libpathod/pathod.py b/libpathod/pathod.py index c84be4205..6fc0d204c 100644 --- a/libpathod/pathod.py +++ b/libpathod/pathod.py @@ -1,7 +1,8 @@ -import urllib, threading, re +import urllib, threading, re, logging from netlib import tcp, http, odict, wsgi import version, app, rparse + class PathodError(Exception): pass diff --git a/pathoc b/pathoc index 12edc34a5..0115516bb 100755 --- a/pathoc +++ b/pathoc @@ -10,7 +10,7 @@ if __name__ == "__main__": parser.add_argument('request', type=str, nargs="+", help='Request specification') args = parser.parse_args() - + if args.port is None: port = 443 if args.ssl else 80 else: diff --git a/pathod b/pathod index b4ee7eb33..7ba5ad805 100755 --- a/pathod +++ b/pathod @@ -1,5 +1,5 @@ #!/usr/bin/env python -import argparse, sys +import argparse, sys, logging from libpathod import pathod, utils, version if __name__ == "__main__": @@ -14,6 +14,11 @@ if __name__ == "__main__": "-d", dest='staticdir', default=None, type=str, help='Directory for static files.' ) + parser.add_argument( + "--debug", dest='debug', default=False, + action="store_true", + help='Enable debug output.' + ) parser.add_argument( "-s", dest='ssl', default=False, action="store_true", @@ -50,6 +55,18 @@ if __name__ == "__main__": parser.error("Invalid anchor specification: %s"%i) alst.append(parts) + root = logging.getLogger() + if root.handlers: + for handler in root.handlers: + root.removeHandler(handler) + logging.basicConfig( + format='%(asctime)s: %(message)s', + datefmt='%d-%m-%y %I:%M:%S', + level=logging.DEBUG + ) + if not args.debug: + logging.disable(logging.DEBUG) + try: pd = pathod.Pathod( (args.address, args.port),