mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-05 23:07:44 +00:00
types/logger: add TestLogger
We have this in another repo and I wanted it here too. Updates #cleanup Change-Id: If93dc73f11eaaada5024acf2a885a153b88db5a0 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
77060c4d89
commit
ecc1d6907b
@ -373,3 +373,19 @@ func (a asJSONResult) Format(s fmt.State, verb rune) {
|
||||
}
|
||||
s.Write(v)
|
||||
}
|
||||
|
||||
// TBLogger is the testing.TB subset needed by TestLogger.
|
||||
type TBLogger interface {
|
||||
Helper()
|
||||
Logf(format string, args ...any)
|
||||
}
|
||||
|
||||
// TestLogger returns a logger that logs to tb.Logf
|
||||
// with a prefix to make it easier to distinguish spam
|
||||
// from explicit test failures.
|
||||
func TestLogger(tb TBLogger) Logf {
|
||||
return func(format string, args ...any) {
|
||||
tb.Helper()
|
||||
tb.Logf(" ... "+format, args...)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user