Skip to content

Commit

Permalink
test: slog add other Attr example
Browse files Browse the repository at this point in the history
  • Loading branch information
ttys3 committed Aug 10, 2023
1 parent b8b0490 commit ea06f45
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions testdata/src/a/all/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"log/slog"
"time"

kitlog "github.com/go-kit/log"
"github.com/go-logr/logr"
Expand Down Expand Up @@ -127,4 +128,7 @@ func ExampleSlog() {

slog.Info("with group ok", "key1", "value1", slog.Group("group_val_key", "gkey1", "gvalue1", "gkey2", "gvalue2"))
slog.Info("with group missing val", "key1", "value1", slog.Group("group_val_key", "gkey1", "gvalue1", "gkey2")) // want `odd number of arguments passed as key-value pairs for logging`

slog.Info("with attributes", slog.Time("time", time.Now()), slog.String("method", "POST"), slog.Int("status", 301))
slog.Info("with attributes missing val", slog.Time("time", time.Now()), slog.String("method", "POST"), slog.Int("status", 301), "key_only") // want `odd number of arguments passed as key-value pairs for logging`
}

0 comments on commit ea06f45

Please sign in to comment.