logger: add nop logger (#384)

pull/367/merge
Michael Fridman 2022-07-13 08:18:12 -04:00 committed by GitHub
parent 496d7cdf15
commit 0a72970737
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

15
log.go
View File

@ -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...) }
// NopLogger returns a logger that discards all logged output.
func NopLogger() Logger {
return &nopLogger{}
}
type nopLogger struct{}
var _ Logger = (*nopLogger)(nil)
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{}) {}