Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,33 @@ type Logger interface {
Panicf(format string, v ...interface{})
}

// nullLogger is a Logger that does nothing.
type nullLogger struct{}

func (nullLogger) Fatal(_ ...interface{}) {
// Do nothing
}

func (nullLogger) Fatalf(_ string, _ ...interface{}) {
// Do nothing
}

func (nullLogger) Print(_ ...interface{}) {
// Do nothing
}

func (nullLogger) Printf(_ string, _ ...interface{}) {
// Do nothing
}

func (nullLogger) Panic(_ ...interface{}) {
// Do nothing
}

func (nullLogger) Panicf(_ string, _ ...interface{}) {
// Do nothing
}

// LoggingCollector provides different methods for collecting and classifying
// log messages.
type LoggingCollector interface {
Expand Down Expand Up @@ -324,6 +351,10 @@ func LC() LoggingCollector {
return defaultLoggingCollector
}

func DisableLogging() {
defaultLoggingCollector.SetLogger(nullLogger{})
}

func init() {
if logLevel := strings.ToUpper(os.Getenv("UPPER_DB_LOG")); logLevel != "" {
for ll := range logLevels {
Expand Down