diff options
Diffstat (limited to 'cmd/monfront/main.go')
-rw-r--r-- | cmd/monfront/main.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/cmd/monfront/main.go b/cmd/monfront/main.go index 19be6e0..2fcf15b 100644 --- a/cmd/monfront/main.go +++ b/cmd/monfront/main.go @@ -283,7 +283,7 @@ func checkAction(con *Context) { setClause = "enabled = false, updated = now()" case "delete_check": if _, err := DB.Exec(`delete from checks where id = any ($1::bigint[])`, pq.Array(checks)); err != nil { - log.Printf("could not delete checks '%s': %s", checks, err) + con.log.Info("could not delete checks", "checks", checks, "error", err) con.Error = "could not delete checks" returnError(http.StatusInternalServerError, con, con.w) return @@ -315,7 +315,7 @@ func checkAction(con *Context) { hostname, err := os.Hostname() if err != nil { - log.Printf("could not resolve hostname: %s", err) + con.log.Info("could not resolve hostname", "error", err) con.Error = "could not resolve hostname" returnError(http.StatusInternalServerError, con, con.w) return @@ -326,7 +326,7 @@ func checkAction(con *Context) { from checks_notify cn join active_checks ac on cn.check_id = ac.check_id where cn.check_id = any ($1::bigint[])`, pq.Array(&checks), &hostname); err != nil { - log.Printf("could not acknowledge check: %s", err) + con.log.Info("could not acknowledge check", "error", err) con.Error = "could not acknowledge check" returnError(http.StatusInternalServerError, con, con.w) return @@ -343,7 +343,7 @@ func checkAction(con *Context) { if err != nil { con.w.WriteHeader(http.StatusInternalServerError) fmt.Fprintf(con.w, "could not store changes") - log.Printf("could not adjust checks %#v: %s", checks, err) + con.log.Info("could not adjust checks", "error", err, "checks", checks) return } con.w.WriteHeader(http.StatusSeeOther) @@ -354,7 +354,7 @@ func checkAction(con *Context) { if err != nil { con.Error = "could not uncomment checks" returnError(http.StatusInternalServerError, con, con.w) - log.Printf("could not uncomment checks: %s", err) + con.log.Info("could not uncomment checks", "error", err) return } con.w.WriteHeader(http.StatusSeeOther) @@ -381,20 +381,20 @@ func checkAction(con *Context) { if err != nil { con.w.WriteHeader(http.StatusInternalServerError) fmt.Fprintf(con.w, "could not store changes") - log.Printf("could not adjust checks %#v: %s", checks, err) + con.log.Info("could not adjust checks", "checks", checks, "error", err) return } con.w.WriteHeader(http.StatusSeeOther) return } -func returnError(status int, con interface{}, w http.ResponseWriter) { +func returnError(status int, con *Context, w http.ResponseWriter) { w.Header()["Content-Type"] = []string{"text/html"} w.WriteHeader(status) if err := Tmpl.ExecuteTemplate(w, "error", con); err != nil { w.WriteHeader(http.StatusInternalServerError) w.Write([]byte("problem with a template")) - log.Printf("could not execute template: %s", err) + con.log.Info("could not execute template", "error", err) } } |