Skip to content

Comments

Suppress log output when running tests#15

Merged
utkarsh5026 merged 1 commit intomainfrom
fix-log-in-tests
Feb 19, 2026
Merged

Suppress log output when running tests#15
utkarsh5026 merged 1 commit intomainfrom
fix-log-in-tests

Conversation

@utkarsh5026
Copy link
Owner

Fix: Suppress log output during test runs

Title: Suppress logger output when running under go test

Summary:

  • InitDefault() in pkg/logging/logger.go now detects when the process is running under go test via testing.Testing() and redirects the slog handler's writer to io.Discard
  • Prevents noisy log output from polluting test results and making failures harder to diagnose
  • No change to log behavior in production/non-test execution paths

Changes:

  • pkg/logging/logger.go — import testing; conditionally set writer to io.Discard when testing.Testing() returns true

Use testing.Testing() in InitDefault() to redirect log
output to io.Discard during test runs, eliminating noise
from test output without requiring changes to test files.
@utkarsh5026 utkarsh5026 self-assigned this Feb 19, 2026
@utkarsh5026 utkarsh5026 merged commit 3456a41 into main Feb 19, 2026
3 of 8 checks passed
@utkarsh5026 utkarsh5026 deleted the fix-log-in-tests branch February 19, 2026 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant