Skip to content

Commit

Permalink
Update readme with correct examples for golang.org/x/exp v0.0.0-20230…
Browse files Browse the repository at this point in the history
…522175609
  • Loading branch information
neilotoole committed May 31, 2023
1 parent 61b2dad commit 73bb58f
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,18 @@ You can exercise full control over the handler using `slogt.Factory()`.

```go
func TestSomething(T *testing.T) {
// This factory returns a slog.Handler using slog.LevelError.
f := slogt.Factory(func(w io.Writer) slog.Handler {
return slog.HandlerOptions{
// This factory returns a slog.Handler using slog.LevelError.
f := slogt.Factory(func(w io.Writer) slog.Handler {
opts := &slog.HandlerOptions{
Level: slog.LevelError,
}.NewTextHandler(w)
})

log := slogt.New(t, f)
}
return slog.NewTextHandler(w, opts)
})

log := slogt.New(t, f)
}
```


## Deficiency

Calling `t.Log()` prints the callsite as the first element
Expand Down Expand Up @@ -167,9 +167,11 @@ see the correct callsite alongside the incorrect one, you can do this:
```go
func TestCaller(t *testing.T) {
f := slogt.Factory(func(w io.Writer) slog.Handler {
return slog.HandlerOptions{
opts := &slog.HandlerOptions{
AddSource: true,
}.NewTextHandler(w)
}

return slog.NewTextHandler(w, opts)
})

log := slogt.New(t, f)
Expand Down

0 comments on commit 73bb58f

Please sign in to comment.