From 3f0d95955cb15ad797accab7f4857fa72ca3005b Mon Sep 17 00:00:00 2001 From: Jay Date: Thu, 23 Apr 2026 19:00:01 -0400 Subject: [PATCH] Update log levels. --- transport/connection.go | 2 +- transport/logging_test.go | 36 ++++++++++++++++++------------------ transport/socket.go | 6 +++--- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/transport/connection.go b/transport/connection.go index 95ea008..7354fae 100644 --- a/transport/connection.go +++ b/transport/connection.go @@ -136,7 +136,7 @@ func (c *Connection) Connect(ctx context.Context) error { } if c.logger != nil { - c.logger.Info("connecting") + c.logger.Debug("connecting") } c.state = StateConnecting diff --git a/transport/logging_test.go b/transport/logging_test.go index 6129b43..fdbf57c 100644 --- a/transport/logging_test.go +++ b/transport/logging_test.go @@ -46,9 +46,9 @@ func TestConnectLogging(t *testing.T) { records := mockHandler.GetRecords() expected := []honeybeetest.ExpectedLog{ - log(slog.LevelInfo, "connecting", map[string]any{}), - log(slog.LevelInfo, "dialing", map[string]any{"attempt": 1}), - log(slog.LevelInfo, "dial successful", map[string]any{"attempt": 1}), + log(slog.LevelDebug, "connecting", map[string]any{}), + log(slog.LevelDebug, "dialing", map[string]any{"attempt": 1}), + log(slog.LevelDebug, "dial successful", map[string]any{"attempt": 1}), log(slog.LevelInfo, "connected", map[string]any{}), } @@ -85,12 +85,12 @@ func TestConnectLogging(t *testing.T) { records := mockHandler.GetRecords() expected := []honeybeetest.ExpectedLog{ - log(slog.LevelInfo, "connecting", map[string]any{}), - log(slog.LevelInfo, "dialing", map[string]any{"attempt": 1}), - log(slog.LevelWarn, "dial failed, retrying", map[string]any{"attempt": 1, "error": dialErr}), - log(slog.LevelInfo, "dialing", map[string]any{"attempt": 2}), - log(slog.LevelWarn, "dial failed, retrying", map[string]any{"attempt": 2, "error": dialErr}), - log(slog.LevelInfo, "dialing", map[string]any{"attempt": 3}), + log(slog.LevelDebug, "connecting", map[string]any{}), + log(slog.LevelDebug, "dialing", map[string]any{"attempt": 1}), + log(slog.LevelDebug, "dial failed, retrying", map[string]any{"attempt": 1, "error": dialErr}), + log(slog.LevelDebug, "dialing", map[string]any{"attempt": 2}), + log(slog.LevelDebug, "dial failed, retrying", map[string]any{"attempt": 2, "error": dialErr}), + log(slog.LevelDebug, "dialing", map[string]any{"attempt": 3}), log(slog.LevelError, "dial failed, max retries reached", map[string]any{"attempt": 3, "error": dialErr}), log(slog.LevelError, "connection failed", map[string]any{"error": dialErr}), } @@ -134,13 +134,13 @@ func TestConnectLogging(t *testing.T) { records := mockHandler.GetRecords() expected := []honeybeetest.ExpectedLog{ - log(slog.LevelInfo, "connecting", map[string]any{}), - log(slog.LevelInfo, "dialing", map[string]any{"attempt": 1}), - log(slog.LevelWarn, "dial failed, retrying", map[string]any{"attempt": 1, "error": dialErr}), - log(slog.LevelInfo, "dialing", map[string]any{"attempt": 2}), - log(slog.LevelWarn, "dial failed, retrying", map[string]any{"attempt": 2, "error": dialErr}), - log(slog.LevelInfo, "dialing", map[string]any{"attempt": 3}), - log(slog.LevelInfo, "dial successful", map[string]any{"attempt": 3}), + log(slog.LevelDebug, "connecting", map[string]any{}), + log(slog.LevelDebug, "dialing", map[string]any{"attempt": 1}), + log(slog.LevelDebug, "dial failed, retrying", map[string]any{"attempt": 1, "error": dialErr}), + log(slog.LevelDebug, "dialing", map[string]any{"attempt": 2}), + log(slog.LevelDebug, "dial failed, retrying", map[string]any{"attempt": 2, "error": dialErr}), + log(slog.LevelDebug, "dialing", map[string]any{"attempt": 3}), + log(slog.LevelDebug, "dial successful", map[string]any{"attempt": 3}), log(slog.LevelInfo, "connected", map[string]any{}), } @@ -161,14 +161,14 @@ func TestCloseLogging(t *testing.T) { honeybeetest.Eventually(t, func() bool { return honeybeetest.FindLogRecord( - mockHandler.GetRecords(), slog.LevelInfo, "closed") != nil + mockHandler.GetRecords(), slog.LevelInfo, "connection closed") != nil }, "expected log") records := mockHandler.GetRecords() expected := []honeybeetest.ExpectedLog{ log(slog.LevelInfo, "shutting down", map[string]any{}), - log(slog.LevelInfo, "closed", map[string]any{}), + log(slog.LevelInfo, "connection closed", map[string]any{}), } honeybeetest.AssertLogSequence(t, records, expected) diff --git a/transport/socket.go b/transport/socket.go index 7eaf327..986c11f 100644 --- a/transport/socket.go +++ b/transport/socket.go @@ -65,13 +65,13 @@ func AcquireSocket( for { if logger != nil { - logger.Info("dialing", "attempt", retryMgr.RetryCount()+1) + logger.Debug("dialing", "attempt", retryMgr.RetryCount()+1) } socket, resp, err := dialer.DialContext(ctx, url, nil) if err == nil { if logger != nil { - logger.Info("dial successful", "attempt", retryMgr.RetryCount()+1) + logger.Debug("dial successful", "attempt", retryMgr.RetryCount()+1) } return socket, resp, nil } @@ -88,7 +88,7 @@ func AcquireSocket( delay := retryMgr.CalculateDelay() if logger != nil { - logger.Warn("dial failed, retrying", + logger.Debug("dial failed, retrying", "error", err, "attempt", retryMgr.RetryCount()+1, "next_delay", delay)