summaryrefslogtreecommitdiff
path: root/sqlite.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sqlite.go46
1 files changed, 0 insertions, 46 deletions
diff --git a/sqlite.go b/sqlite.go
deleted file mode 100644
index 8ee6325..0000000
--- a/sqlite.go
+++ /dev/null
@@ -1,46 +0,0 @@
-//go:build sqlite
-
-package main
-
-import (
- "context"
- "database/sql"
- "log"
- "log/slog"
-
- sqldblogger "github.com/simukti/sqldb-logger"
-)
-
-type logger struct {
-}
-
-func (l logger) Log(ctx context.Context, level sqldblogger.Level, msg string, data map[string]interface{}) {
- attrs := make([]slog.Attr, 0, len(data))
-
- for k, v := range data {
- attrs = append(attrs, slog.Any(k, v))
- }
-
- var lvl slog.Level
- switch level {
- case sqldblogger.LevelDebug, sqldblogger.LevelTrace:
- lvl = slog.LevelDebug
- case sqldblogger.LevelInfo:
- lvl = slog.LevelInfo
- case sqldblogger.LevelError:
- lvl = slog.LevelError
- }
-
- slog.LogAttrs(ctx, lvl, msg, attrs...)
-}
-
-func openDB(dsn string) *sql.DB {
- db, err := sql.Open(driverName, dsn)
- if err != nil {
- log.Fatal(err)
- }
- slog.SetLogLoggerLevel(slog.LevelDebug)
- return sqldblogger.OpenDriver(dsn, db.Driver(), logger{},
- sqldblogger.WithSQLQueryAsMessage(false),
- sqldblogger.WithMinimumLevel(sqldblogger.LevelTrace))
-}