Signed-off-by: brookjeynes me@brookjeynes.dev
+7
-4
internal/db/db.go
+7
-4
internal/db/db.go
···
4
4
"context"
5
5
"database/sql"
6
6
"fmt"
7
+
"log/slog"
7
8
"strings"
8
9
9
10
_ "github.com/mattn/go-sqlite3"
···
11
12
12
13
type DB struct {
13
14
*sql.DB
15
+
logger *slog.Logger
14
16
}
15
17
16
18
type Execer interface {
···
24
26
PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
25
27
}
26
28
27
-
func Make(dbPath string) (*DB, error) {
29
+
func Make(ctx context.Context, dbPath string, logger *slog.Logger) (*DB, error) {
28
30
opts := []string{
29
31
"_foreign_keys=1",
30
32
"_journal_mode=WAL",
···
37
39
return nil, fmt.Errorf("failed to open db: %w", err)
38
40
}
39
41
40
-
ctx := context.Background()
41
-
42
42
conn, err := db.Conn(ctx)
43
43
if err != nil {
44
44
return nil, err
···
231
231
return nil, fmt.Errorf("failed to execute db create statement: %w", err)
232
232
}
233
233
234
-
return &DB{db}, nil
234
+
return &DB{
235
+
db,
236
+
logger,
237
+
}, nil
235
238
}
+1
-1
internal/server/app.go
+1
-1
internal/server/app.go
History
1 round
0 comments
brookjeynes.dev
submitted
#0
1 commit
expand
collapse
feat(db): use slogger
Signed-off-by: brookjeynes <me@brookjeynes.dev>
expand 0 comments
pull request successfully merged