# HG changeset patch # User David Barts # Date 1559259403 25200 # Node ID 997d0c8c174fde66fcb0d995aa6dc043328fa613 # Parent 969f515b505b49260874c5b38a83c2553b0c0713 Default for the launch callable should be not to log. diff -r 969f515b505b -r 997d0c8c174f launch --- a/launch Thu May 30 14:44:09 2019 -0700 +++ b/launch Thu May 30 16:36:43 2019 -0700 @@ -7,6 +7,7 @@ import os, sys from argparse import ArgumentParser +import logging from tincan import launch, ENCODING # V a r i a b l e s @@ -26,7 +27,10 @@ opt("directory", default=".", help="directory to serve", nargs='?') opt("path", default="/", help="URL path to serve", nargs='?') args = parser.parse_args(sys.argv[1:]) -app, errors = launch(fsroot=args.directory, urlroot=args.path, debug=args.debug, +mylog = logging.getLogger(MYNAME) +mylog.addHandler(logging.StreamHandler()) +mylog.setLevel(logging.DEBUG if args.debug else logging.INFO) +app, errors = launch(fsroot=args.directory, urlroot=args.path, logger=mylog, encoding=args.encoding, static=args.static) if errors: action = "continuing" if args.force else "aborting" diff -r 969f515b505b -r 997d0c8c174f tincan.py --- a/tincan.py Thu May 30 14:44:09 2019 -0700 +++ b/tincan.py Thu May 30 16:36:43 2019 -0700 @@ -21,7 +21,6 @@ from threading import Lock import time import urllib -import uuid import bottle @@ -883,16 +882,15 @@ elif S_ISDIR(etype): self._launch(subdir + [entry]) -def launch(fsroot=None, urlroot='/', logger=None, debug=False, - encoding=ENCODING, static=False, multithread=True): +_BITBUCKET = logging.getLogger(__name__) +_BITBUCKET.addHandler(logging.NullHandler) + +def launch(fsroot=None, urlroot='/', logger=_BITBUCKET, encoding=ENCODING, + static=False, multithread=True): """ Launch and return a TinCan webapp. Does not run the app; it is the caller's responsibility to call app.run() """ - if logger is None: - logger = logging.getLogger("{0!s}-{1!s}".format(__name__, uuid.uuid1())) - logger.addHandler(logging.StreamHandler()) - logger.setLevel(logging.DEBUG if debug else logging.INFO) if fsroot is None: fsroot = os.getcwd() launcher = _Launcher(fsroot, urlroot, multithread)