implements: initialize the internal package with minimal logging support

This log.go file establishes the ability for the package's user to hand
it any logger that meets the very minimal interface.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2020-05-04 15:00:53 -04:00 committed by John Mulligan
parent f082075f26
commit 80300e4e5a
1 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,20 @@
package implements
// DebugLogger is a simple interface to allow debug logging w/in the
// implements package.
type DebugLogger interface {
Printf(format string, v ...interface{})
}
// NoOpLogger is a dummy logger that generates no output.
type NoOpLogger struct{}
// Printf implements the DebugLogger interface.
func (NoOpLogger) Printf(_ string, _ ...interface{}) {}
var logger DebugLogger = NoOpLogger{}
// SetLogger will set the given debug logger for the whole implements package.
func SetLogger(l DebugLogger) {
logger = l
}