diff --git a/duplicacy/duplicacy_main.go b/duplicacy/duplicacy_main.go index b502a43..91d7a32 100644 --- a/duplicacy/duplicacy_main.go +++ b/duplicacy/duplicacy_main.go @@ -159,6 +159,10 @@ func setGlobalOptions(context *cli.Context) { }() } + for _, logID := range context.GlobalStringSlice("suppress") { + duplicacy.SuppressLog(logID) + } + duplicacy.RunInBackground = context.GlobalBool("background") } @@ -2069,6 +2073,11 @@ func main() { Name: "comment", Usage: "add a comment to identify the process", }, + cli.StringSliceFlag{ + Name: "suppress, s", + Usage: "suppress logs with the specified id", + Argument: "", + }, } app.HideVersion = true diff --git a/src/duplicacy_log.go b/src/duplicacy_log.go index d9b154d..d71852d 100644 --- a/src/duplicacy_log.go +++ b/src/duplicacy_log.go @@ -45,6 +45,13 @@ func setTestingT(t *testing.T) { testingT = t } +// Contains the ids of logs that won't be displayed +var suppressedLogs map[string]bool = map[string]bool{} + +func SuppressLog(id string) { + suppressedLogs[id] = true +} + func getLevelName(level int) string { switch level { case DEBUG: @@ -145,6 +152,12 @@ func logf(level int, logID string, format string, v ...interface{}) { defer logMutex.Unlock() if level >= loggingLevel { + if level <= ERROR && len(suppressedLogs) > 0 { + if _, found := suppressedLogs[logID]; found { + return + } + } + if printLogHeader { fmt.Printf("%s %s %s %s\n", now.Format("2006-01-02 15:04:05.000"), getLevelName(level), logID, message)