From 81a2d308f03e99065142afef2ffc04a3accdf39b Mon Sep 17 00:00:00 2001 From: brent s Date: Sun, 13 Mar 2022 13:29:31 -0400 Subject: [PATCH] Add NullLogger. For when you need a Logger but don't want one. ;) --- logging/funcs_nulllogger.go | 66 +++++++++++++++++++++++++++++++++++++ logging/types.go | 5 ++- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 logging/funcs_nulllogger.go diff --git a/logging/funcs_nulllogger.go b/logging/funcs_nulllogger.go new file mode 100644 index 0000000..07d5c3b --- /dev/null +++ b/logging/funcs_nulllogger.go @@ -0,0 +1,66 @@ +package logging + +// Setup does nothing at all; it's here for interface compat. 🙃 +func (l *NullLogger) Setup() (err error) { + return +} + +// DoDebug does nothing at all; it's here for interface compat. 🙃 +func (l *NullLogger) DoDebug(d bool) (err error) { + return +} + +// SetPrefix does nothing at all; it's here for interface compat. 🙃 +func (l *NullLogger) SetPrefix(p string) (err error) { + return +} + +// GetPrefix does nothing at all; it's here for interface compat. 🙃 +func (l *NullLogger) GetPrefix() (p string, err error) { + return +} + +// Shutdown does nothing at all; it's here for interface compat. 🙃 +func (l *NullLogger) Shutdown() (err error) { + return +} + +// Alert does nothing at all; it's here for interface compat. 🙃 +func (l *NullLogger) Alert(s string, v ...interface{}) (err error) { + return +} + +// Crit does nothing at all; it's here for interface compat. 🙃 +func (l *NullLogger) Crit(s string, v ...interface{}) (err error) { + return +} + +// Debug does nothing at all; it's here for interface compat. 🙃 +func (l *NullLogger) Debug(s string, v ...interface{}) (err error) { + return +} + +// Emerg does nothing at all; it's here for interface compat. 🙃 +func (l *NullLogger) Emerg(s string, v ...interface{}) (err error) { + return +} + +// Err does nothing at all; it's here for interface compat. 🙃 +func (l *NullLogger) Err(s string, v ...interface{}) (err error) { + return +} + +// Info does nothing at all; it's here for interface compat. 🙃 +func (l *NullLogger) Info(s string, v ...interface{}) (err error) { + return +} + +// Notice does nothing at all; it's here for interface compat. 🙃 +func (l *NullLogger) Notice(s string, v ...interface{}) (err error) { + return +} + +// Warning does nothing at all; it's here for interface compat. 🙃 +func (l *NullLogger) Warning(s string, v ...interface{}) (err error) { + return +} diff --git a/logging/types.go b/logging/types.go index 02da98f..eda3e92 100644 --- a/logging/types.go +++ b/logging/types.go @@ -2,7 +2,7 @@ package logging import ( "log" - `os` + "os" ) /* @@ -86,6 +86,9 @@ type FileLogger struct { writer *os.File } +// NullLogger is used mainly for test implementations, mockup code, etc. It does absolutely nothing with all messages sent to it. +type NullLogger struct{} + // MultiLogger is used to contain one or more Loggers and present them all as a single Logger. type MultiLogger struct { /*