Skip to content

Commit

Permalink
Merge pull request #8 from craftamap/gh-7-remove-debug-logs
Browse files Browse the repository at this point in the history
gh-7 only print debug logs if debug flag is set
  • Loading branch information
craftamap authored May 13, 2021
2 parents e91d299 + 478338f commit b53fa84
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/commands/pr/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ func manageReviewers(bbrepo *bbgit.BitbucketRepo, c *client.Client, currentUser
nameToUUID[name] = rev
}
if len(listOfNames) == 0 {
logging.Warning("No reviwers to add available")
logging.Warning("No reviewers to add available")
continue
}
var addedReviewers []string
Expand Down
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func init() {
rootCmd.PersistentFlags().StringVar(&username, "username", "", "username")
rootCmd.PersistentFlags().StringVar(&password, "password", "", "app password")
rootCmd.PersistentFlags().StringVar(&remoteName, "remote", "origin", "if you are in a repository and don't want to interact with the default origin, you can change it")
rootCmd.PersistentFlags().BoolVar(&logging.PrintDebugLogs, "debug", false, "enabling this flag allows debug logs to be printed")

err := viper.BindPFlag("username", rootCmd.PersistentFlags().Lookup("username"))
if err != nil {
Expand Down
12 changes: 10 additions & 2 deletions util/logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@ import (
"github.com/logrusorgru/aurora"
)

var (
PrintDebugLogs = false
)

func Debug(message ...interface{}) {
fmt.Printf("%s%s\n", aurora.BgCyan(":: "+aurora.Bold("DEBUG: ").String()), fmt.Sprint(message...))
if PrintDebugLogs {
fmt.Printf("%s%s\n", aurora.BgCyan(":: "+aurora.Bold("DEBUG: ").String()), fmt.Sprint(message...))
}
}

func Debugf(message ...interface{}) {
fmt.Printf("%s%s\n", aurora.BgCyan(":: "+aurora.Bold("DEBUG: ").String()), fmt.Sprintf(message[0].(string), message[1:]...))
if PrintDebugLogs {
fmt.Printf("%s%s\n", aurora.BgCyan(":: "+aurora.Bold("DEBUG: ").String()), fmt.Sprintf(message[0].(string), message[1:]...))
}
}

func Error(message ...interface{}) {
Expand Down

0 comments on commit b53fa84

Please # to comment.