From f1965fb64e6ba0ddf4fbcfa70d5609d74954080e Mon Sep 17 00:00:00 2001 From: "M. J. Fromberger" Date: Mon, 18 Nov 2024 10:43:41 -0800 Subject: [PATCH] cmd/bsky-webhook: don't log opaque bytes on error (#8) An error in a Jetstream message currently logs the raw message as bytes, which the slog output renders as [01 02 03 ...] format. This is noisy, and also hard to debug, so let's truncate them and quote them for the logger. --- cmd/bsky-webhook/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/bsky-webhook/main.go b/cmd/bsky-webhook/main.go index 69a7da1..7804346 100644 --- a/cmd/bsky-webhook/main.go +++ b/cmd/bsky-webhook/main.go @@ -207,7 +207,8 @@ func websocketConnection(ctx context.Context, wsUrl url.URL) error { err = readJetstreamMessage(ctx, jetstreamMessage, bsky) if err != nil { - log.Println("error reading jetstream message: ", jetstreamMessage, err) + msg := jetstreamMessage[:min(32, len(jetstreamMessage))] + log.Printf("error reading jetstream message %q: %v", msg, err) continue } }