Skip to content
Snippets Groups Projects
Commit 49e119bd authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

fixed the log level flags

parent 7cc1a664
No related branches found
No related tags found
No related merge requests found
...@@ -182,7 +182,8 @@ Flags: ...@@ -182,7 +182,8 @@ Flags:
--unsafe-channel-creation Turns off the user identity authenticated --unsafe-channel-creation Turns off the user identity authenticated
channel check, automatically approving channel check, automatically approving
authenticated channels 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 --waitTimeout uint The number of seconds to wait for messages to
arrive (default 15) arrive (default 15)
-w, --writeContact string Write the contact file for this user to this -w, --writeContact string Write the contact file for this user to this
......
...@@ -260,7 +260,7 @@ func printRoundResults(allRoundsSucceeded, timedOut bool, ...@@ -260,7 +260,7 @@ func printRoundResults(allRoundsSucceeded, timedOut bool,
} }
func createClient() *api.Client { func createClient() *api.Client {
initLog(viper.GetBool("verbose"), viper.GetString("log")) initLog(viper.GetUint("logLevel"), viper.GetString("log"))
jww.INFO.Printf(Version()) jww.INFO.Printf(Version())
pass := viper.GetString("password") pass := viper.GetString("password")
...@@ -547,7 +547,7 @@ func getUIDFromString(idStr string) *id.ID { ...@@ -547,7 +547,7 @@ func getUIDFromString(idStr string) *id.ID {
return ID return ID
} }
func initLog(verbose bool, logPath string) { func initLog(threshold uint, logPath string) {
if logPath != "-" && logPath != "" { if logPath != "-" && logPath != "" {
// Disable stdout output // Disable stdout output
jww.SetStdoutOutput(ioutil.Discard) jww.SetStdoutOutput(ioutil.Discard)
...@@ -560,14 +560,16 @@ func initLog(verbose bool, logPath string) { ...@@ -560,14 +560,16 @@ func initLog(verbose bool, logPath string) {
jww.SetLogOutput(logOutput) jww.SetLogOutput(logOutput)
} }
if verbose { if threshold>1{
jww.SetStdoutThreshold(jww.LevelTrace) jww.SetStdoutThreshold(jww.LevelTrace)
jww.SetLogThreshold(jww.LevelTrace) jww.SetLogThreshold(jww.LevelTrace)
}else if threshold == 1{
jww.SetStdoutThreshold(jww.LevelDebug)
jww.SetLogThreshold(jww.LevelDebug)
}else{ }else{
jww.SetStdoutThreshold(jww.LevelInfo) jww.SetStdoutThreshold(jww.LevelInfo)
jww.SetLogThreshold(jww.LevelInfo) jww.SetLogThreshold(jww.LevelInfo)
} }
} }
func isValidUser(usr []byte) (bool, *id.ID) { func isValidUser(usr []byte) (bool, *id.ID) {
...@@ -615,7 +617,7 @@ func init() { ...@@ -615,7 +617,7 @@ func init() {
// Here you will define your flags and configuration settings. // Here you will define your flags and configuration settings.
// Cobra supports persistent flags, which, if defined here, // Cobra supports persistent flags, which, if defined here,
// will be global for your application. // will be global for your application.
rootCmd.PersistentFlags().BoolP("verbose", "v", false, rootCmd.PersistentFlags().UintP("logLevel", "v", 0,
"Verbose mode for debugging") "Verbose mode for debugging")
viper.BindPFlag("verbose", rootCmd.PersistentFlags().Lookup("verbose")) viper.BindPFlag("verbose", rootCmd.PersistentFlags().Lookup("verbose"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment