Skip to content

Commit

Permalink
Add the Mute levels to to logger
Browse files Browse the repository at this point in the history
  • Loading branch information
haroldcampbell committed Jun 16, 2021
1 parent 926c778 commit a32c65e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 12 additions & 0 deletions utils/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ func YellowText(v interface{}) string {
}

func Tag(format string, v ...interface{}) {
if muteLevel == FullMute {
return
}

message := fmt.Sprintf(format, v...)
log.Printf("%s %s", CyanText("==>"), message)
}
Expand Down Expand Up @@ -114,6 +118,10 @@ func PrettyMongoString(v interface{}) string {
}

func Log(stem string, format string, v ...interface{}) {
if muteLevel == FullMute || muteLevel == TestMute {
return
}

t := time.Now()

var buf []byte
Expand All @@ -128,6 +136,10 @@ func Log(stem string, format string, v ...interface{}) {
}

func Error(stem string, format string, v ...interface{}) {
if muteLevel == FullMute {
return
}

t := time.Now()

var buf []byte
Expand Down
6 changes: 0 additions & 6 deletions utils/routine_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@ const (
FullMute
)

// var isRunningInTest = false
var muteLevel MuteLevel

func init() {
// isRunningInTest = flag.Lookup("test.v") != nil
// fmt.Printf("test.v: %v\n", flag.Lookup("test.v") == nil)
}

func SetMuteLevel(l MuteLevel) {
muteLevel = l
}
Expand Down

0 comments on commit a32c65e

Please sign in to comment.