From 81fe4e8a12b362f7de9a97210f950c388d047664 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Sat, 26 Aug 2023 14:14:51 -0400 Subject: Switch from ln to slog ln had a good run, but it's not going to last for the long term. I'm going to standardize everything on log/slog and deprecate ln. Closes #385 Signed-off-by: Xe Iaso --- web/error.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'web/error.go') diff --git a/web/error.go b/web/error.go index 923b29e..e23871d 100644 --- a/web/error.go +++ b/web/error.go @@ -5,10 +5,9 @@ package web import ( "fmt" "io/ioutil" + "log/slog" "net/http" "net/url" - - "within.website/ln" ) // NewError creates an Error based on an expected HTTP status code vs data populated @@ -45,13 +44,13 @@ func (e Error) Error() string { return fmt.Sprintf("%s %s: wanted status code %d, got: %d: %v", e.Method, e.URL, e.WantStatus, e.GotStatus, e.ResponseBody) } -// F ields for logging. -func (e Error) F() ln.F { - return ln.F{ - "err_want_status": e.WantStatus, - "err_got_status": e.GotStatus, - "err_url": e.URL, - "err_method": e.Method, - "err_response_body": e.ResponseBody, - } +// LogValue formats this Error for slog. +func (e Error) LogValue() slog.Value { + return slog.GroupValue( + slog.Int("want_status", e.WantStatus), + slog.Int("got_status", e.GotStatus), + slog.String("url", e.URL.String()), + slog.String("method", e.Method), + slog.String("body", e.ResponseBody), + ) } -- cgit v1.2.3