diff --git a/plugin/teksi_wastewater/utils/database_utils.py b/plugin/teksi_wastewater/utils/database_utils.py index ae49987b4..e575ecca3 100644 --- a/plugin/teksi_wastewater/utils/database_utils.py +++ b/plugin/teksi_wastewater/utils/database_utils.py @@ -1,6 +1,7 @@ import collections import configparser import os +import re from typing import List from .plugin_utils import logger @@ -87,10 +88,13 @@ def read_pgservice(service_name): # Path for pg_service.conf if os.environ.get("PGSERVICEFILE"): PG_CONFIG_PATH = os.environ.get("PGSERVICEFILE") + logger.debug(f"PGSERVICEFILE: {PG_CONFIG_PATH}") elif os.environ.get("PGSYSCONFDIR"): PG_CONFIG_PATH = os.path.join(os.environ.get("PGSYSCONFDIR"), "pg_service.conf") + logger.debug(f"PGSYSCONFDIR: {PG_CONFIG_PATH}") else: PG_CONFIG_PATH = os.path.expanduser("~/.pg_service.conf") + logger.debug(f"PG_CONFIG_PATH: {PG_CONFIG_PATH}") config = configparser.ConfigParser() if os.path.exists(PG_CONFIG_PATH): @@ -134,6 +138,8 @@ def get_pgconf_as_psycopg_dsn() -> List[str]: parts = [] for key in pgconf: parts.append(f"{key}={pgconf[key]}") + dsn_masked_pwd = re.sub(r"(password=).+", r"\1[PASSWORD]", " ".join(parts)) + logger.debug(f"psycopg dsn: {dsn_masked_pwd}") return " ".join(parts) @staticmethod