Error logging

This commit is contained in:
binwiederhier 2023-02-06 16:01:32 -05:00
parent b5158adb51
commit 9b54f63eb1
5 changed files with 60 additions and 22 deletions

View file

@ -3,6 +3,7 @@ package server
import (
"encoding/json"
"fmt"
"heckel.io/ntfy/log"
"net/http"
)
@ -23,6 +24,14 @@ func (e errHTTP) JSON() string {
return string(b)
}
func (e errHTTP) Context() log.Context {
return log.Context{
"error": e.Message,
"error_code": e.Code,
"http_status": e.HTTPCode,
}
}
func wrapErrHTTP(err *errHTTP, message string, args ...any) *errHTTP {
return &errHTTP{
Code: err.Code,