Update log levels.
This commit is contained in:
@@ -136,7 +136,7 @@ func (c *Connection) Connect(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if c.logger != nil {
|
if c.logger != nil {
|
||||||
c.logger.Info("connecting")
|
c.logger.Debug("connecting")
|
||||||
}
|
}
|
||||||
|
|
||||||
c.state = StateConnecting
|
c.state = StateConnecting
|
||||||
|
|||||||
+18
-18
@@ -46,9 +46,9 @@ func TestConnectLogging(t *testing.T) {
|
|||||||
records := mockHandler.GetRecords()
|
records := mockHandler.GetRecords()
|
||||||
|
|
||||||
expected := []honeybeetest.ExpectedLog{
|
expected := []honeybeetest.ExpectedLog{
|
||||||
log(slog.LevelInfo, "connecting", map[string]any{}),
|
log(slog.LevelDebug, "connecting", map[string]any{}),
|
||||||
log(slog.LevelInfo, "dialing", map[string]any{"attempt": 1}),
|
log(slog.LevelDebug, "dialing", map[string]any{"attempt": 1}),
|
||||||
log(slog.LevelInfo, "dial successful", map[string]any{"attempt": 1}),
|
log(slog.LevelDebug, "dial successful", map[string]any{"attempt": 1}),
|
||||||
log(slog.LevelInfo, "connected", map[string]any{}),
|
log(slog.LevelInfo, "connected", map[string]any{}),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,12 +85,12 @@ func TestConnectLogging(t *testing.T) {
|
|||||||
records := mockHandler.GetRecords()
|
records := mockHandler.GetRecords()
|
||||||
|
|
||||||
expected := []honeybeetest.ExpectedLog{
|
expected := []honeybeetest.ExpectedLog{
|
||||||
log(slog.LevelInfo, "connecting", map[string]any{}),
|
log(slog.LevelDebug, "connecting", map[string]any{}),
|
||||||
log(slog.LevelInfo, "dialing", map[string]any{"attempt": 1}),
|
log(slog.LevelDebug, "dialing", map[string]any{"attempt": 1}),
|
||||||
log(slog.LevelWarn, "dial failed, retrying", map[string]any{"attempt": 1, "error": dialErr}),
|
log(slog.LevelDebug, "dial failed, retrying", map[string]any{"attempt": 1, "error": dialErr}),
|
||||||
log(slog.LevelInfo, "dialing", map[string]any{"attempt": 2}),
|
log(slog.LevelDebug, "dialing", map[string]any{"attempt": 2}),
|
||||||
log(slog.LevelWarn, "dial failed, retrying", map[string]any{"attempt": 2, "error": dialErr}),
|
log(slog.LevelDebug, "dial failed, retrying", map[string]any{"attempt": 2, "error": dialErr}),
|
||||||
log(slog.LevelInfo, "dialing", map[string]any{"attempt": 3}),
|
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, "dial failed, max retries reached", map[string]any{"attempt": 3, "error": dialErr}),
|
||||||
log(slog.LevelError, "connection failed", map[string]any{"error": dialErr}),
|
log(slog.LevelError, "connection failed", map[string]any{"error": dialErr}),
|
||||||
}
|
}
|
||||||
@@ -134,13 +134,13 @@ func TestConnectLogging(t *testing.T) {
|
|||||||
records := mockHandler.GetRecords()
|
records := mockHandler.GetRecords()
|
||||||
|
|
||||||
expected := []honeybeetest.ExpectedLog{
|
expected := []honeybeetest.ExpectedLog{
|
||||||
log(slog.LevelInfo, "connecting", map[string]any{}),
|
log(slog.LevelDebug, "connecting", map[string]any{}),
|
||||||
log(slog.LevelInfo, "dialing", map[string]any{"attempt": 1}),
|
log(slog.LevelDebug, "dialing", map[string]any{"attempt": 1}),
|
||||||
log(slog.LevelWarn, "dial failed, retrying", map[string]any{"attempt": 1, "error": dialErr}),
|
log(slog.LevelDebug, "dial failed, retrying", map[string]any{"attempt": 1, "error": dialErr}),
|
||||||
log(slog.LevelInfo, "dialing", map[string]any{"attempt": 2}),
|
log(slog.LevelDebug, "dialing", map[string]any{"attempt": 2}),
|
||||||
log(slog.LevelWarn, "dial failed, retrying", map[string]any{"attempt": 2, "error": dialErr}),
|
log(slog.LevelDebug, "dial failed, retrying", map[string]any{"attempt": 2, "error": dialErr}),
|
||||||
log(slog.LevelInfo, "dialing", map[string]any{"attempt": 3}),
|
log(slog.LevelDebug, "dialing", map[string]any{"attempt": 3}),
|
||||||
log(slog.LevelInfo, "dial successful", map[string]any{"attempt": 3}),
|
log(slog.LevelDebug, "dial successful", map[string]any{"attempt": 3}),
|
||||||
log(slog.LevelInfo, "connected", map[string]any{}),
|
log(slog.LevelInfo, "connected", map[string]any{}),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,14 +161,14 @@ func TestCloseLogging(t *testing.T) {
|
|||||||
|
|
||||||
honeybeetest.Eventually(t, func() bool {
|
honeybeetest.Eventually(t, func() bool {
|
||||||
return honeybeetest.FindLogRecord(
|
return honeybeetest.FindLogRecord(
|
||||||
mockHandler.GetRecords(), slog.LevelInfo, "closed") != nil
|
mockHandler.GetRecords(), slog.LevelInfo, "connection closed") != nil
|
||||||
}, "expected log")
|
}, "expected log")
|
||||||
|
|
||||||
records := mockHandler.GetRecords()
|
records := mockHandler.GetRecords()
|
||||||
|
|
||||||
expected := []honeybeetest.ExpectedLog{
|
expected := []honeybeetest.ExpectedLog{
|
||||||
log(slog.LevelInfo, "shutting down", map[string]any{}),
|
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)
|
honeybeetest.AssertLogSequence(t, records, expected)
|
||||||
|
|||||||
+3
-3
@@ -65,13 +65,13 @@ func AcquireSocket(
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
if logger != nil {
|
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)
|
socket, resp, err := dialer.DialContext(ctx, url, nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if logger != nil {
|
if logger != nil {
|
||||||
logger.Info("dial successful", "attempt", retryMgr.RetryCount()+1)
|
logger.Debug("dial successful", "attempt", retryMgr.RetryCount()+1)
|
||||||
}
|
}
|
||||||
return socket, resp, nil
|
return socket, resp, nil
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ func AcquireSocket(
|
|||||||
delay := retryMgr.CalculateDelay()
|
delay := retryMgr.CalculateDelay()
|
||||||
|
|
||||||
if logger != nil {
|
if logger != nil {
|
||||||
logger.Warn("dial failed, retrying",
|
logger.Debug("dial failed, retrying",
|
||||||
"error", err,
|
"error", err,
|
||||||
"attempt", retryMgr.RetryCount()+1,
|
"attempt", retryMgr.RetryCount()+1,
|
||||||
"next_delay", delay)
|
"next_delay", delay)
|
||||||
|
|||||||
Reference in New Issue
Block a user