mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-10 00:51:07 +00:00
all: update tests to use tstest.MemLogger
And give MemLogger a mutex, as one caller had, which does match the logf contract better. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
48bdffd395
commit
640134421e
@@ -127,10 +127,13 @@ func (lt *LogLineTracker) Close() {
|
||||
// MemLogger is a bytes.Buffer with a Logf method for tests that want
|
||||
// to log to a buffer.
|
||||
type MemLogger struct {
|
||||
sync.Mutex
|
||||
bytes.Buffer
|
||||
}
|
||||
|
||||
func (ml *MemLogger) Logf(format string, args ...interface{}) {
|
||||
ml.Lock()
|
||||
defer ml.Unlock()
|
||||
fmt.Fprintf(&ml.Buffer, format, args...)
|
||||
if !mem.HasSuffix(mem.B(ml.Buffer.Bytes()), mem.S("\n")) {
|
||||
ml.Buffer.WriteByte('\n')
|
||||
|
Reference in New Issue
Block a user