From 086ba55a15dc04914cba500f7ead61dec5490162 Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Sat, 29 Nov 2025 13:45:29 +0100 Subject: Add debug facilities. --- db/conn.rkt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'db/conn.rkt') diff --git a/db/conn.rkt b/db/conn.rkt index 42a75c0..11abc19 100644 --- a/db/conn.rkt +++ b/db/conn.rkt @@ -1,22 +1,27 @@ #lang racket -(require db) - (provide current-conn connect! disconnect! with-db with-tx) +(require db + "../debug.rkt") + (define current-conn (make-parameter #f)) (define (connect! #:path [path 'memory]) - (unless (connection? (current-conn)) - (current-conn (sqlite3-connect #:database path #:mode 'create)))) + (if (connection? (current-conn)) + (debug-log (format "Connection already instantiated: ~a" (current-conn))) + (begin + (current-conn (sqlite3-connect #:database path #:mode 'create)) + (debug-log (format "Connection instantiated: ~a" (current-conn)))))) (define (disconnect!) (disconnect (current-conn)) - (current-conn #f)) + (current-conn #f) + (debug-log "Connection disconnected.")) (define-syntax-rule (with-db body ...) (begin -- cgit v1.2.3