From f9a712bc33640c91e102d609406ffaebf71da7ba Mon Sep 17 00:00:00 2001 From: Colin Henry Date: Fri, 5 Aug 2022 22:04:20 -0700 Subject: [PATCH] added to the logger interface --- log/logger.go | 19 +++++++++---------- log/none.go | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 log/none.go diff --git a/log/logger.go b/log/logger.go index cf35360..4a63899 100644 --- a/log/logger.go +++ b/log/logger.go @@ -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. type Logger interface { - Print(v ...interface{}) - Printf(format string, v ...interface{}) - Println(v ...interface{}) + Fatal(v ...any) + Fatalf(format string, v ...any) + 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{}) {} diff --git a/log/none.go b/log/none.go new file mode 100644 index 0000000..3a3880b --- /dev/null +++ b/log/none.go @@ -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) {}