Skip to content
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

gdtcontext.WithDebug() no args to stdout #24

Merged
merged 1 commit into from
Jun 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package context
import (
"context"
"io"
"os"

gdttypes "github.com/gdt-dev/gdt/types"
"github.com/samber/lo"
Expand Down Expand Up @@ -100,18 +101,15 @@ func WithFixtures(fixtures map[string]gdttypes.Fixture) ContextModifier {
// SetDebug sets gdt's debug logging to the supplied `io.Writer`.
//
// The `writers` parameters is optional. If no `io.Writer` objects are
// supplied, gdt will output debug messages using the `testing.T.Log[f]()`
// function. This means that you will only get these debug messages if you call
// the `go test` tool with the `-v` option (either as `go test -v` or with `go
// test -v=test2json`.
// supplied, gdt will output debug messages to stdout.
func SetDebug(
ctx context.Context,
writers ...io.Writer,
) context.Context {
if len(writers) == 0 {
// This simply triggers a call to t.Logf() when WithDebug() is
// called with no parameters...
writers = []io.Writer{io.Discard}
// This triggers writes to stdout when WithDebug() is called with no
// parameters...
writers = []io.Writer{os.Stdout}
}
return context.WithValue(ctx, debugKey, writers)
}
Expand Down
Loading