Monorepo for Tangled tangled.org

knotserver: pass logger into DB #877

merged opened by oppi.li targeting master from op/wonqmpyrknoq
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:qfpnj4og54vl56wngdriaxug/sh.tangled.repo.pull/3m7p7tctaru22
+6 -1
Interdiff #0 โ†’ #1
+6 -1
knotserver/db/db.go
··· 1 1 package db 2 2 3 3 import ( 4 + "context" 4 5 "database/sql" 5 6 "log/slog" 6 7 "strings" 7 8 8 9 _ "github.com/mattn/go-sqlite3" 10 + "tangled.org/core/log" 9 11 ) 10 12 11 13 type DB struct { ··· 13 15 logger *slog.Logger 14 16 } 15 17 16 - func Setup(dbPath string, logger *slog.Logger) (*DB, error) { 18 + func Setup(ctx context.Context, dbPath string) (*DB, error) { 17 19 // https://github.com/mattn/go-sqlite3#connection-string 18 20 opts := []string{ 19 21 "_foreign_keys=1", ··· 21 23 22 24 "_auto_vacuum=incremental", 23 25 } 26 + 27 + logger := log.FromContext(ctx) 28 + logger = log.SubLogger(logger, "db") 24 29 25 30 db, err := sql.Open("sqlite3", dbPath+"?"+strings.Join(opts, "&")) 26 31 if err != nil {
knotserver/server.go

This file has not been changed.

History

2 rounds 0 comments
sign up or login to add to the discussion
oppi.li submitted #1
1 commit
expand
knotserver: pass logger into DB
expand 0 comments
pull request successfully merged
oppi.li submitted #0
1 commit
expand
knotserver: pass logger into DB
expand 0 comments