Skip to content

fix: Replace zerolog.Nop() with conditional logger #1352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mem
Copy link
Contributor

@mem mem commented Jun 18, 2025

We have a few places where we use zerolog.Nop() in tests, which is fine if we want to cut down the noise, but it's very difficult to use if there are failures.

Change the direct calls to zerolog.Nop() to testhelper.Logger(t), which will create a zerolog instance configured to filter out everything below the error level. If the user passes the verbose flag to go test, when it switches to using debug level.

Also add another helper, K6Path(*testing.T), which builds the path to the k6 binary used in tests, and fails if that doesn't exist, to prevent harder to debug errors down the test.

@mem mem requested a review from a team as a code owner June 18, 2025 16:49
@mem mem requested review from Pokom and The-9880 June 18, 2025 16:49
@mem mem force-pushed the mem/add-logger-and-k6-testhelper branch from 2914566 to dc95f38 Compare June 18, 2025 17:43
We have a few places where we use zerolog.Nop() in tests, which is fine
if we want to cut down the noise, but it's very difficult to use if
there are failures.

Change the direct calls to zerolog.Nop() to testhelper.Logger(t), which
will create a zerolog instance configured to filter out everything below
the error level. If the user passes the verbose flag to `go test`, when
it switches to using debug level.

Also add another helper, K6Path(*testing.T), which builds the path to
the k6 binary used in tests, and fails if that doesn't exist, to prevent
harder to debug errors down the test.

Signed-off-by: Marcelo E. Magallon <[email protected]>
@mem mem force-pushed the mem/add-logger-and-k6-testhelper branch from dc95f38 to fc0fc01 Compare June 18, 2025 19:58
Copy link
Member

@nadiamoe nadiamoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is neat, thank you!

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.

2 participants