From: Michael Tremer Date: Fri, 5 Dec 2025 15:34:37 +0000 (+0000) Subject: dnsbl: Log any SQL statements when in debug mode X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa8c9776f1e1bc158586df966c22fa7dd741a17d;p=dbl.git dnsbl: Log any SQL statements when in debug mode Signed-off-by: Michael Tremer --- diff --git a/src/dnsbl/__init__.py b/src/dnsbl/__init__.py index 783e19f..b5a0ea1 100644 --- a/src/dnsbl/__init__.py +++ b/src/dnsbl/__init__.py @@ -29,7 +29,9 @@ from . import logger log = logging.getLogger(__name__) class Backend(object): - def __init__(self, config=None): + def __init__(self, config=None, debug=False): + self.debug = debug + # Parse the configuration file self.config = self.parse_config(config) @@ -58,7 +60,15 @@ class Backend(object): uri = self.config.get("database", "uri") # Create the database engine - return sqlmodel.create_engine(uri) + return sqlmodel.create_engine( + uri, + + # Log more if we are running in debug mode + echo=self.debug, + + # Use our own logger + logging_name=log.name, + ) def update_sources(self): """ diff --git a/src/scripts/dnsbl.in b/src/scripts/dnsbl.in index 4106bbe..1c99f59 100644 --- a/src/scripts/dnsbl.in +++ b/src/scripts/dnsbl.in @@ -68,7 +68,10 @@ class CLI(object): dnsbl.logger.set_level(logging.DEBUG) # Initialize the backend - backend = dnsbl.Backend(args.config) + backend = dnsbl.Backend( + config = args.config, + debug = args.debug, + ) # Call the handler function ret = args.func(backend, args)