aboutsummaryrefslogtreecommitdiff
path: root/cmd/monfront/create.go
diff options
context:
space:
mode:
authorGibheer <gibheer+git@zero-knowledge.org>2023-08-17 22:05:46 +0200
committerGibheer <gibheer+git@zero-knowledge.org>2023-08-17 22:05:46 +0200
commit8e6e01f47c320f862b9ba44815587006ba80cf77 (patch)
treecb59d7d3a3c84a4d54ac2a26e436f2b2a83cdfab /cmd/monfront/create.go
parent10f7eb53f4370cab6c1ff390773772389d500e59 (diff)
switch from log to slog
This commit replaces the various log entry points with a common logger provided via context. This is helpful as it groups all log entries together via the txid and should help in the future when debugging cascading errors.
Diffstat (limited to 'cmd/monfront/create.go')
-rw-r--r--cmd/monfront/create.go7
1 files changed, 3 insertions, 4 deletions
diff --git a/cmd/monfront/create.go b/cmd/monfront/create.go
index 43805a1..e11679f 100644
--- a/cmd/monfront/create.go
+++ b/cmd/monfront/create.go
@@ -3,7 +3,6 @@ package main
import (
"database/sql"
"fmt"
- "log"
"net/http"
"strings"
)
@@ -38,14 +37,14 @@ func showCreate(con *Context) {
rows, err := DB.Query(prim.query)
defer rows.Close()
if err != nil {
- log.Printf("could not get commands: %s", err)
+ con.log.Info("could not get commands", "error", err)
con.Error = "could not get commands"
returnError(http.StatusInternalServerError, con, con.w)
return
}
result, err := rowsToResult(rows)
if err != nil {
- log.Printf("could not get %s: %s", prim.name, err)
+ con.log.Info("could not get", "primitive", prim.name, "error", err)
con.Error = "could not get " + prim.name
returnError(http.StatusInternalServerError, con, con.w)
return
@@ -137,7 +136,7 @@ func addCreate(con *Context) {
stmt := `insert into ` + t.Table + `(` + strings.Join(t.Fields, ",") + `) values (` + strings.Join(vals, ",") + `)`
_, err := DB.Exec(stmt, fields...)
if err != nil {
- log.Printf("could not insert new %s: %s", addType, err)
+ con.log.Info("could not insert new type", "type", addType, "error", err)
con.Error = "could not insert new " + addType
returnError(http.StatusInternalServerError, con, con.w)
return