]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
feat(tools): add a -L,--log-level option to async_to_sync.py
authorDenis Laxalde <denis.laxalde@dalibo.com>
Mon, 4 Mar 2024 07:27:14 +0000 (08:27 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 1 Apr 2024 23:02:29 +0000 (23:02 +0000)
We'll use DEBUG messages in the next commit.

tools/async_to_sync.py

index 3ff046e767355a19e650fa08cc1f8b874d7e49d0..1ceefd234e788755564345e233caa36fb34cc2c2 100755 (executable)
@@ -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",