diff --git a/README.md b/README.md index 7986edf64e12e514eb135ce0f5112e770de9e82f..0aa1f5f3645eeb389453e9a2261e169ba7466b45 100644 --- a/README.md +++ b/README.md @@ -182,7 +182,8 @@ Flags: --unsafe-channel-creation Turns off the user identity authenticated channel check, automatically approving authenticated channels - -v, --verbose Verbose mode for debugging + -v, --logLevel Level of debugging to print (0 = info, + 1 = debug, >1 = trace). (Default info) --waitTimeout uint The number of seconds to wait for messages to arrive (default 15) -w, --writeContact string Write the contact file for this user to this diff --git a/cmd/root.go b/cmd/root.go index a5b550f5ec405391b4ae96e57eb83f1d26f18ed2..b65e68cd50eba6251f4d541f2ea2277f396f308e 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -260,7 +260,7 @@ func printRoundResults(allRoundsSucceeded, timedOut bool, } func createClient() *api.Client { - initLog(viper.GetBool("verbose"), viper.GetString("log")) + initLog(viper.GetUint("logLevel"), viper.GetString("log")) jww.INFO.Printf(Version()) pass := viper.GetString("password") @@ -547,7 +547,7 @@ func getUIDFromString(idStr string) *id.ID { return ID } -func initLog(verbose bool, logPath string) { +func initLog(threshold uint, logPath string) { if logPath != "-" && logPath != "" { // Disable stdout output jww.SetStdoutOutput(ioutil.Discard) @@ -560,14 +560,16 @@ func initLog(verbose bool, logPath string) { jww.SetLogOutput(logOutput) } - if verbose { + if threshold>1{ jww.SetStdoutThreshold(jww.LevelTrace) jww.SetLogThreshold(jww.LevelTrace) - } else { + }else if threshold == 1{ + jww.SetStdoutThreshold(jww.LevelDebug) + jww.SetLogThreshold(jww.LevelDebug) + }else{ jww.SetStdoutThreshold(jww.LevelInfo) jww.SetLogThreshold(jww.LevelInfo) } - } func isValidUser(usr []byte) (bool, *id.ID) { @@ -615,7 +617,7 @@ func init() { // Here you will define your flags and configuration settings. // Cobra supports persistent flags, which, if defined here, // will be global for your application. - rootCmd.PersistentFlags().BoolP("verbose", "v", false, + rootCmd.PersistentFlags().UintP("logLevel", "v", 0, "Verbose mode for debugging") viper.BindPFlag("verbose", rootCmd.PersistentFlags().Lookup("verbose"))