From 5ec7ac1d022cf77571633202e399cadfe5a1902e Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 14 May 2020 10:05:32 -0700 Subject: [PATCH] tstest: document PanicOnLog --- tstest/log.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tstest/log.go b/tstest/log.go index cb3e6b55f..201aae757 100644 --- a/tstest/log.go +++ b/tstest/log.go @@ -29,13 +29,15 @@ func UnfixLogs(t *testing.T) { defer log.SetOutput(os.Stderr) } -type panicLogWriter struct { -} - -func (w *panicLogWriter) Write(b []byte) (int, error) { - panic("please use tailscale.com/logger.Logf instead of the log module") +type panicLogWriter struct{} + +func (panicLogWriter) Write(b []byte) (int, error) { + panic("please use tailscale.com/logger.Logf instead of the log package") } +// PanicOnLog modifies the standard library log package's default output to +// an io.Writer that panics, to root out code that's not plumbing their logging +// through explicit tailscale.com/logger.Logf paths. func PanicOnLog() { - log.SetOutput(&panicLogWriter{}) + log.SetOutput(panicLogWriter{}) }