From cf74025ac31dd89677b14dcbe507411e6d6212ed Mon Sep 17 00:00:00 2001 From: Michael Fridman Date: Tue, 12 Jul 2022 22:22:35 -0400 Subject: [PATCH 1/2] logger: add discard logger --- log.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/log.go b/log.go index 7f531a270..23b37378d 100644 --- a/log.go +++ b/log.go @@ -28,3 +28,18 @@ func (*stdLogger) Fatalf(format string, v ...interface{}) { std.Fatalf(format, v func (*stdLogger) Print(v ...interface{}) { std.Print(v...) } func (*stdLogger) Println(v ...interface{}) { std.Println(v...) } func (*stdLogger) Printf(format string, v ...interface{}) { std.Printf(format, v...) } + +// DiscardLogger returns a logger that discards all logged output. +func DiscardLogger() Logger { + return &discardLogger{} +} + +type discardLogger struct{} + +var _ Logger = (*discardLogger)(nil) + +func (*discardLogger) Fatal(v ...interface{}) {} +func (*discardLogger) Fatalf(format string, v ...interface{}) {} +func (*discardLogger) Print(v ...interface{}) {} +func (*discardLogger) Println(v ...interface{}) {} +func (*discardLogger) Printf(format string, v ...interface{}) {} From b8db600fe35911a64b90ea5de4f4d1c312755637 Mon Sep 17 00:00:00 2001 From: Michael Fridman Date: Wed, 13 Jul 2022 08:15:27 -0400 Subject: [PATCH 2/2] Change name to NopLogger --- log.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/log.go b/log.go index 23b37378d..9d59ec89e 100644 --- a/log.go +++ b/log.go @@ -29,17 +29,17 @@ func (*stdLogger) Print(v ...interface{}) { std.Print(v...) } func (*stdLogger) Println(v ...interface{}) { std.Println(v...) } func (*stdLogger) Printf(format string, v ...interface{}) { std.Printf(format, v...) } -// DiscardLogger returns a logger that discards all logged output. -func DiscardLogger() Logger { - return &discardLogger{} +// NopLogger returns a logger that discards all logged output. +func NopLogger() Logger { + return &nopLogger{} } -type discardLogger struct{} +type nopLogger struct{} -var _ Logger = (*discardLogger)(nil) +var _ Logger = (*nopLogger)(nil) -func (*discardLogger) Fatal(v ...interface{}) {} -func (*discardLogger) Fatalf(format string, v ...interface{}) {} -func (*discardLogger) Print(v ...interface{}) {} -func (*discardLogger) Println(v ...interface{}) {} -func (*discardLogger) Printf(format string, v ...interface{}) {} +func (*nopLogger) Fatal(v ...interface{}) {} +func (*nopLogger) Fatalf(format string, v ...interface{}) {} +func (*nopLogger) Print(v ...interface{}) {} +func (*nopLogger) Println(v ...interface{}) {} +func (*nopLogger) Printf(format string, v ...interface{}) {}