Skip to content

Commit

Permalink
test: remove dropTimestamp option that was used for old test consistency
Browse files Browse the repository at this point in the history
This was previous iterations where testing was done with a Mock and
where non-deterministic output couldn't be used. Tests are now using
both the slogtest suite as well as other custom testing that supports
timestamps.

Signed-off-by: TJ Hoplock <[email protected]>
  • Loading branch information
tjhop committed Nov 20, 2024
1 parent 40f1ad4 commit 284c7f2
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ import (

var _ slog.Handler = GoKitHandler{}

// For tests only:
// Enable this to skip adding slog's default timestamp kv pair into the kv
// pairs passed to the handler's underlying go-kit logger. This is needed so
// that non-deterministic output can be stripped from the log calls and play
// nicely with Mock.
var dropTimestamp = false

var defaultGoKitLogger = log.NewLogfmtLogger(os.Stderr)

// GoKitHandler implements the slog.Handler interface. It holds an internal
Expand Down Expand Up @@ -70,7 +63,7 @@ func (h GoKitHandler) Handle(_ context.Context, record slog.Record) error {
// preformatted vals, all things we more or less know the size of at
// creation time here.
pairs := make([]any, 0, (2 * record.NumAttrs()))
if !record.Time.IsZero() && !dropTimestamp {
if !record.Time.IsZero() {
pairs = append(pairs, "time", record.Time)
}
pairs = append(pairs, "msg", record.Message)
Expand Down

0 comments on commit 284c7f2

Please sign in to comment.