added to the logger interface

This commit is contained in:
Colin Henry 2022-08-05 22:04:20 -07:00
parent dc5f8b6e5a
commit f9a712bc33
2 changed files with 23 additions and 10 deletions

View File

@ -2,14 +2,13 @@ package log
// Logger is a logging interface with only the essentials that a function that needs to log should care about. Compatible with standard Go logger. // Logger is a logging interface with only the essentials that a function that needs to log should care about. Compatible with standard Go logger.
type Logger interface { type Logger interface {
Print(v ...interface{}) Fatal(v ...any)
Printf(format string, v ...interface{}) Fatalf(format string, v ...any)
Println(v ...interface{}) Fatalln(v ...any)
Panic(v ...any)
Panicf(format string, v ...any)
Panicln(v ...any)
Print(v ...any)
Printf(format string, v ...any)
Println(v ...any)
} }
// None provides a logger that doesnt log anything
type None struct{}
func (n None) Print(v ...interface{}) {}
func (n None) Printf(format string, v ...interface{}) {}
func (n None) Println(v ...interface{}) {}

14
log/none.go Normal file
View File

@ -0,0 +1,14 @@
package log
// None provides a logger that doesnt log anything
type None struct{}
func (n None) Fatal(v ...any) {}
func (n None) Fatalf(format string, v ...any) {}
func (n None) Fatalln(v ...any) {}
func (n None) Panic(v ...any) {}
func (n None) Panicf(format string, v ...any) {}
func (n None) Panicln(v ...any) {}
func (n None) Print(v ...any) {}
func (n None) Printf(format string, v ...any) {}
func (n None) Println(v ...any) {}