aboutsummaryrefslogtreecommitdiff
path: root/web/error.go
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2023-08-26 14:14:51 -0400
committerXe Iaso <me@xeiaso.net>2023-08-26 14:14:51 -0400
commit81fe4e8a12b362f7de9a97210f950c388d047664 (patch)
treed71d879f62d74e528a1338470df268669e2565be /web/error.go
parent924a12ab6915b7dad147ed57c5a384c142f82c1e (diff)
downloadx-81fe4e8a12b362f7de9a97210f950c388d047664.tar.xz
x-81fe4e8a12b362f7de9a97210f950c388d047664.zip
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 <me@xeiaso.net>
Diffstat (limited to 'web/error.go')
-rw-r--r--web/error.go21
1 files changed, 10 insertions, 11 deletions
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),
+ )
}