]> git.ipfire.org Git - dbl.git/commitdiff
dnsbl: Log any SQL statements when in debug mode
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 5 Dec 2025 15:34:37 +0000 (15:34 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 5 Dec 2025 15:34:37 +0000 (15:34 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/dnsbl/__init__.py
src/scripts/dnsbl.in

index 783e19fadd5e7737821cd26c5a4f0b839c23c2a4..b5a0ea109bc1b1d75af836c0782434e752c6e31c 100644 (file)
@@ -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):
                """
index 4106bbec0839c9ad7fba8a5da3f74dce4dcb2e31..1c99f59c9b0e4e4b9f654ca0903ad21c9a43ba44 100644 (file)
@@ -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)