diff options
author | Gibheer <gibheer+git@zero-knowledge.org> | 2023-08-17 22:05:46 +0200 |
---|---|---|
committer | Gibheer <gibheer+git@zero-knowledge.org> | 2023-08-17 22:05:46 +0200 |
commit | 8e6e01f47c320f862b9ba44815587006ba80cf77 (patch) | |
tree | cb59d7d3a3c84a4d54ac2a26e436f2b2a83cdfab /cmd/monfront/checks.go | |
parent | 10f7eb53f4370cab6c1ff390773772389d500e59 (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/checks.go')
-rw-r--r-- | cmd/monfront/checks.go | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/cmd/monfront/checks.go b/cmd/monfront/checks.go index d61d337..e6668fd 100644 --- a/cmd/monfront/checks.go +++ b/cmd/monfront/checks.go @@ -2,7 +2,6 @@ package main import ( "database/sql" - "log" "net/http" "time" @@ -101,7 +100,7 @@ func showCheck(con *Context) { } else if err != nil { con.w.WriteHeader(http.StatusInternalServerError) con.w.Write([]byte("problems with the database")) - log.Printf("could not get check details for check id %s: %s", id[0], err) + con.log.Info("could not get check details for check id", "id", id[0], "error", err) return } @@ -114,7 +113,7 @@ func showCheck(con *Context) { rows, err := DB.Query(query, cd.Id) defer rows.Close() if err != nil { - log.Printf("could not load notifications: %s", err) + con.log.Info("could not load notifications", "error", err) con.Error = "could not load notification information" returnError(http.StatusInternalServerError, con, con.w) return @@ -122,7 +121,7 @@ func showCheck(con *Context) { cd.Notifications = []notification{} for rows.Next() { if err := rows.Err(); err != nil { - log.Printf("could not load notifications: %s", err) + con.log.Info("could not load notifications", "error", err) con.Error = "could not load notification information" returnError(http.StatusInternalServerError, con, con.w) return @@ -130,7 +129,7 @@ func showCheck(con *Context) { no := notification{} if err := rows.Scan(&no.Id, &no.State, &no.Output, &no.Inserted, &no.Sent, &no.NotifierName, &no.MappingId); err != nil { - log.Printf("could not scan notifications: %s", err) + con.log.Info("could not scan notifications", "error", err) con.Error = "could not load notification information" returnError(http.StatusInternalServerError, con, con.w) return @@ -141,7 +140,7 @@ func showCheck(con *Context) { if err := con.loadMappings(); err != nil { con.w.WriteHeader(http.StatusInternalServerError) con.w.Write([]byte("problem with the mappings")) - log.Printf("could not load mappings: %s", err) + con.log.Info("could not load mappings", "error", err) return } @@ -188,7 +187,7 @@ func showChecks(con *Context) { if err != nil { con.w.WriteHeader(http.StatusInternalServerError) con.w.Write([]byte("problems with the database")) - log.Printf("could not get check list: %s", err) + con.log.Info("could not get check list", "error", err) return } defer rows.Close() @@ -201,7 +200,7 @@ func showChecks(con *Context) { if err != nil { con.w.WriteHeader(http.StatusInternalServerError) returnError(http.StatusInternalServerError, con, con.w) - log.Printf("could not get check list: %s", err) + con.log.Info("could not get check list", "error", err) return } checks = append(checks, c) @@ -210,14 +209,14 @@ func showChecks(con *Context) { if err := con.loadCommands(); err != nil { con.Error = "could not load commands" returnError(http.StatusInternalServerError, con, con.w) - log.Printf("could not get commands: %s", err) + con.log.Info("could not get commands", "error", err) return } if err := con.loadMappings(); err != nil { con.Error = "could not load mapping data" con.w.WriteHeader(http.StatusInternalServerError) con.w.Write([]byte("problem with the mappings")) - log.Printf("could not load mappings: %s", err) + con.log.Info("could not load mappings", "error", err) return } con.w.Header()["Content-Type"] = []string{"text/html"} |