From 3e6216739fc3291a6e0925157a496cb2df0fb2d5 Mon Sep 17 00:00:00 2001 From: Aryan Date: Fri, 7 Nov 2025 12:24:21 +0000 Subject: [PATCH 1/2] Update log level when configuring websocket --- internal/wslogging/handler.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/wslogging/handler.go b/internal/wslogging/handler.go index 7e229eb..b70a060 100644 --- a/internal/wslogging/handler.go +++ b/internal/wslogging/handler.go @@ -449,13 +449,20 @@ func (h *Handler) connect(wsURL, token string) (*websocket.Conn, error) { // logDiagnostic writes a diagnostic message to the specified writer. // This is used for logging infrastructure issues (not application logs). // Messages are written as JSON to maintain consistency with application logs. +// The log level is determined by the writer: stderr produces ERROR level, stdout produces INFO level. func logDiagnostic(w io.Writer, format string, args ...any) { message := fmt.Sprintf(format, args...) // trim trailing newline if present (we'll add it back after JSON) message = strings.TrimSuffix(message, "\n") + // determine log level based on the writer + level := "info" + if w == os.Stderr { + level = "error" + } + entry := map[string]any{ - "level": "ERROR", + "level": level, "msg": message, "source": "wslogging", "time": time.Now().UTC().Format(time.RFC3339Nano), From 6bdbd7db776149a0c81c6ba9e4c20aec0e80e870 Mon Sep 17 00:00:00 2001 From: Aryan Date: Fri, 7 Nov 2025 12:25:03 +0000 Subject: [PATCH 2/2] Fix comment --- internal/wslogging/handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/wslogging/handler.go b/internal/wslogging/handler.go index b70a060..4225a51 100644 --- a/internal/wslogging/handler.go +++ b/internal/wslogging/handler.go @@ -449,7 +449,7 @@ func (h *Handler) connect(wsURL, token string) (*websocket.Conn, error) { // logDiagnostic writes a diagnostic message to the specified writer. // This is used for logging infrastructure issues (not application logs). // Messages are written as JSON to maintain consistency with application logs. -// The log level is determined by the writer: stderr produces ERROR level, stdout produces INFO level. +// The log level is determined by the writer: stderr produces error level, stdout produces info level. func logDiagnostic(w io.Writer, format string, args ...any) { message := fmt.Sprintf(format, args...) // trim trailing newline if present (we'll add it back after JSON)