diff --git a/cmd/root.go b/cmd/root.go index ffbf3329a99dc1d2ec152e553077d85f569255cc..180fb42e676551fdb663548c5753227d07f87957 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -9,6 +9,7 @@ package cmd import ( "encoding/base64" + "fmt" "github.com/golang/protobuf/proto" "github.com/spf13/cobra" jww "github.com/spf13/jwalterweatherman" @@ -87,13 +88,13 @@ func sessionInitialization() (*id.User, *api.Client) { } // Verify the signature - globals.Log.INFO.Println("Verifying NDF...") + globals.Log.DEBUG.Println("Verifying NDF...") ndfJSON := api.VerifyNDF(string(ndfBytes), ndfPubKey) - globals.Log.INFO.Printf("NDF Verified: %v", ndfJSON) + globals.Log.DEBUG.Printf("NDF Verified: %v", ndfJSON) // Overwrite the network definition with any specified flags overwriteNDF(ndfJSON) - globals.Log.INFO.Printf("Overwrote NDF Vars: %v", ndfJSON) + globals.Log.DEBUG.Printf("Overwrote NDF Vars: %v", ndfJSON) //If no session file is passed initialize with RAM Storage if sessionFile == "" { @@ -283,7 +284,8 @@ func (l *TextListener) Hear(item switchboard.Item, isHeardElsewhere bool) { } else { senderNick = sender.Nick } - globals.Log.INFO.Printf("Message from %v, %v Received: %s\n", large.NewIntFromBytes(message.Sender[:]).Text(10), + fmt.Printf("Message from %v, %v Received: %s\n", + large.NewIntFromBytes(message.Sender[:]).Text(10), senderNick, result.Message) atomic.AddInt64(&l.MessagesReceived, 1) @@ -315,7 +317,7 @@ func (l *ChannelListener) Hear(item switchboard.Item, isHeardElsewhere bool) { senderNick = sender.Nick } - globals.Log.INFO.Printf("Message from channel %v, %v: ", + fmt.Printf("Message from channel %v, %v: ", new(big.Int).SetBytes(message.Sender[:]).Text(10), senderNick) typedBody, _ := parse.Parse(result.Message) speakerId := id.NewUserFromBytes(result.SpeakerID) @@ -392,7 +394,7 @@ var rootCmd = &cobra.Command{ // Handle sending to any other destination wireOut := api.FormatTextMessage(message) - globals.Log.INFO.Printf("Sending Message to %d, %v: %s\n", destinationUserId, + fmt.Printf("Sending Message to %d, %v: %s\n", destinationUserId, recipientNick, message) // Send the message @@ -445,14 +447,17 @@ var rootCmd = &cobra.Command{ } } else { // Wait up to 45 seconds to receive a message - for timeout := time.After(45 * time.Second); ; { + for end, timeout := true, time.After(45*time.Second); end; { if text.MessagesReceived > 0 { - break + end = true } select { case <-timeout: - break + fmt.Println("Timing out client " + + "as no messages have" + + " been received") + end = true default: } } @@ -583,7 +588,7 @@ func initConfig() {} // initLog initializes logging thresholds and the log path. func initLog() { - globals.Log = jww.NewNotepad(jww.LevelError, jww.LevelWarn, os.Stdout, + globals.Log = jww.NewNotepad(jww.LevelError, jww.LevelInfo, os.Stdout, ioutil.Discard, "CLIENT", log.Ldate|log.Ltime) // If verbose flag set then log more info for debugging if verbose || viper.GetBool("verbose") { diff --git a/io/messaging.go b/io/messaging.go index 4b57aedda6d5be152393395a9b9a9a8e29eca6a8..e2c0f22190d396c53c175f66c5259c890a3e1864 100644 --- a/io/messaging.go +++ b/io/messaging.go @@ -208,7 +208,7 @@ func handleE2ESending(session user.Session, // FIXME: This is a hack to prevent a crash, this function should be // able to block until this condition is true. - for timeout := time.After(60 * time.Second); ; { + for end, timeout := false, time.After(60*time.Second); end; { if rekey { // Get send Rekey key, action = km.PopRekey() @@ -217,12 +217,12 @@ func handleE2ESending(session user.Session, key, action = km.PopKey() } if key != nil { - break + end = true } select { case <-timeout: - break + end = true default: } } @@ -288,7 +288,7 @@ func (m *Messaging) MessageReceiver(session user.Session, delay time.Duration) { return default: time.Sleep(delay) - globals.Log.INFO.Printf("Attempting to receive message from gateway") + globals.Log.DEBUG.Printf("Attempting to receive message from gateway") decryptedMessages := m.receiveMessagesFromGateway(session, &pollingMessage) if decryptedMessages != nil { for i := range decryptedMessages {