From 71c4d837ea172212bdbd17e9847505faf5dcae4a Mon Sep 17 00:00:00 2001 From: Emile Fugulin Date: Sat, 20 Feb 2021 20:41:02 -0500 Subject: [PATCH] [LOGGER] Add debug flag for default --- default.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/default.go b/default.go index 23f974c..b6a402f 100644 --- a/default.go +++ b/default.go @@ -7,14 +7,17 @@ import ( ) type defaultLogger struct { + debug bool } -func NewDefault() Logger { - return &defaultLogger{} +func NewDefault(debug bool) Logger { + return &defaultLogger{debug: debug} } -func (*defaultLogger) Debug(msg string, metadata map[string]interface{}) { - log.Printf("[DEBUG] %s %#v", msg, metadata) +func (l *defaultLogger) Debug(msg string, metadata map[string]interface{}) { + if l.debug { + log.Printf("[DEBUG] %s %#v", msg, metadata) + } } func (*defaultLogger) Info(msg string, metadata map[string]interface{}) {