From: Denis Laxalde Date: Mon, 4 Mar 2024 07:27:14 +0000 (+0100) Subject: feat(tools): add a -L,--log-level option to async_to_sync.py X-Git-Tag: 3.2.0~68^2~1 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=280720bd77e9bfcf3c616da6cf508d50cd7ef120;p=thirdparty%2Fpsycopg.git feat(tools): add a -L,--log-level option to async_to_sync.py We'll use DEBUG messages in the next commit. --- diff --git a/tools/async_to_sync.py b/tools/async_to_sync.py index 3ff046e76..1ceefd234 100755 --- a/tools/async_to_sync.py +++ b/tools/async_to_sync.py @@ -60,7 +60,6 @@ PROJECT_DIR = Path(__file__).parent.parent SCRIPT_NAME = os.path.basename(sys.argv[0]) logger = logging.getLogger() -logging.basicConfig(level=logging.INFO, format="%(levelname)s %(message)s") def main() -> int: @@ -68,6 +67,8 @@ def main() -> int: if opt.container: return run_in_container(opt.container) + logging.basicConfig(level=opt.log_level, format="%(levelname)s %(message)s") + current_ver = ".".join(map(str, sys.version_info[:2])) if current_ver != PYVER: logger.warning( @@ -587,6 +588,13 @@ def parse_cmdline() -> Namespace: "if unspecified, the number of processors on the machine will be used" ), ) + parser.add_argument( + "-L", + "--log-level", + choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], + default="INFO", + help="Logger level.", + ) container = parser.add_mutually_exclusive_group() container.add_argument( "--docker",