Skip to content

Commit

Permalink
feat: add debug switch
Browse files Browse the repository at this point in the history
Signed-off-by: Goren G <yong.gu@qlink.mobi>
  • Loading branch information
Goren G committed Aug 30, 2019
1 parent 231bbaa commit a931639
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"os"
)

var IsDebug = false

// Logger is implemented by any logging system that is used for standard logs.
type Logger interface {
Errorf(string, ...interface{})
Expand Down Expand Up @@ -44,13 +46,19 @@ func (l *defaultLog) Infof(f string, v ...interface{}) {
}

func (l *defaultLog) Info(v ...interface{}) {
l.Println(v...)
if IsDebug {
l.Println(v...)
}
}

func (l *defaultLog) Debugf(f string, v ...interface{}) {
l.Printf("DEBUG: "+f+"\n", v...)
if IsDebug {
l.Printf("DEBUG: "+f+"\n", v...)
}
}

func (l *defaultLog) Debug(v ...interface{}) {
l.Println(v...)
if IsDebug {
l.Println(v...)
}
}

0 comments on commit a931639

Please sign in to comment.