Skip to content
Snippets Groups Projects
Commit da81d79c authored by Sydney Anne Erickson's avatar Sydney Anne Erickson :chipmunk:
Browse files

Move fmt.Printf statements to use jww logging

parent 08044ae5
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,6 @@ package cmd ...@@ -9,7 +9,6 @@ package cmd
import ( import (
"encoding/base64" "encoding/base64"
"fmt"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"github.com/spf13/cobra" "github.com/spf13/cobra"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
...@@ -72,7 +71,7 @@ func sessionInitialization() *id.User { ...@@ -72,7 +71,7 @@ func sessionInitialization() *id.User {
if sessionFile == "" { if sessionFile == "" {
client, err = api.NewClient(&globals.RamStorage{}, "") client, err = api.NewClient(&globals.RamStorage{}, "")
if err != nil { if err != nil {
fmt.Printf("Could Not Initialize Ram Storage: %s\n", globals.Log.ERROR.Printf("Could Not Initialize Ram Storage: %s\n",
err.Error()) err.Error())
return id.ZeroID return id.ZeroID
} }
...@@ -88,7 +87,8 @@ func sessionInitialization() *id.User { ...@@ -88,7 +87,8 @@ func sessionInitialization() *id.User {
register = true register = true
} else { } else {
//Fail if any other error is received //Fail if any other error is received
fmt.Printf("Error with file path: %s\n", err1.Error()) globals.Log.ERROR.Printf("Error with file path: %s\n", err1.Error())
return id.ZeroID
} }
} }
...@@ -96,7 +96,7 @@ func sessionInitialization() *id.User { ...@@ -96,7 +96,7 @@ func sessionInitialization() *id.User {
client, err = api.NewClient(nil, sessionFile) client, err = api.NewClient(nil, sessionFile)
if err != nil { if err != nil {
fmt.Printf("Could Not Initialize OS Storage: %s\n", err.Error()) globals.Log.ERROR.Printf("Could Not Initialize OS Storage: %s\n", err.Error())
return id.ZeroID return id.ZeroID
} }
} }
...@@ -113,7 +113,7 @@ func sessionInitialization() *id.User { ...@@ -113,7 +113,7 @@ func sessionInitialization() *id.User {
// If gwAddr was not passed via command line, check config file // If gwAddr was not passed via command line, check config file
if len(gateways) < 1 { if len(gateways) < 1 {
// No gateways in config file or passed via command line // No gateways in config file or passed via command line
fmt.Printf("Error: No gateway specified! Add to" + globals.Log.ERROR.Printf("Error: No gateway specified! Add to" +
" configuration file or pass via command line using -g!\n") " configuration file or pass via command line using -g!\n")
return id.ZeroID return id.ZeroID
} else { } else {
...@@ -150,7 +150,7 @@ func sessionInitialization() *id.User { ...@@ -150,7 +150,7 @@ func sessionInitialization() *id.User {
uid, err = client.Register(userId != 0, regCode, "", mint, &grp) uid, err = client.Register(userId != 0, regCode, "", mint, &grp)
if err != nil { if err != nil {
fmt.Printf("Could Not Register User: %s\n", err.Error()) globals.Log.ERROR.Printf("Could Not Register User: %s\n", err.Error())
return id.ZeroID return id.ZeroID
} }
...@@ -168,7 +168,7 @@ func sessionInitialization() *id.User { ...@@ -168,7 +168,7 @@ func sessionInitialization() *id.User {
// This will also register the user email with UDB // This will also register the user email with UDB
_, err = client.Login(uid, userEmail) _, err = client.Login(uid, userEmail)
if err != nil { if err != nil {
fmt.Printf("Could Not Log In: %s\n", err) globals.Log.ERROR.Printf("Could Not Log In: %s\n", err)
return id.ZeroID return id.ZeroID
} }
...@@ -228,7 +228,7 @@ func (l *FallbackListener) Hear(item switchboard.Item, isHeardElsewhere bool) { ...@@ -228,7 +228,7 @@ func (l *FallbackListener) Hear(item switchboard.Item, isHeardElsewhere bool) {
senderNick = sender.Nick senderNick = sender.Nick
} }
atomic.AddInt64(&l.messagesReceived, 1) atomic.AddInt64(&l.messagesReceived, 1)
fmt.Printf("Message of type %v from %q, %v received with fallback: %s\n", globals.Log.INFO.Println("Message of type %v from %q, %v received with fallback: %s\n",
message.MessageType, *message.Sender, senderNick, message.MessageType, *message.Sender, senderNick,
string(message.Body)) string(message.Body))
} }
...@@ -258,7 +258,7 @@ func (l *TextListener) Hear(item switchboard.Item, isHeardElsewhere bool) { ...@@ -258,7 +258,7 @@ func (l *TextListener) Hear(item switchboard.Item, isHeardElsewhere bool) {
} else { } else {
senderNick = sender.Nick senderNick = sender.Nick
} }
fmt.Printf("Message from %v, %v Received: %s\n", large.NewIntFromBytes(message.Sender[:]).Text(10), globals.Log.INFO.Println("Message from %v, %v Received: %s\n", large.NewIntFromBytes(message.Sender[:]).Text(10),
senderNick, result.Message) senderNick, result.Message)
atomic.AddInt64(&l.messagesReceived, 1) atomic.AddInt64(&l.messagesReceived, 1)
...@@ -282,7 +282,7 @@ func (l *ChannelListener) Hear(item switchboard.Item, isHeardElsewhere bool) { ...@@ -282,7 +282,7 @@ func (l *ChannelListener) Hear(item switchboard.Item, isHeardElsewhere bool) {
senderNick = sender.Nick senderNick = sender.Nick
} }
fmt.Printf("Message from channel %v, %v: ", globals.Log.INFO.Println("Message from channel %v, %v: ",
new(big.Int).SetBytes(message.Sender[:]).Text(10), senderNick) new(big.Int).SetBytes(message.Sender[:]).Text(10), senderNick)
typedBody, _ := parse.Parse(result.Message) typedBody, _ := parse.Parse(result.Message)
speakerId := id.NewUserFromBytes(result.SpeakerID) speakerId := id.NewUserFromBytes(result.SpeakerID)
...@@ -358,7 +358,7 @@ var rootCmd = &cobra.Command{ ...@@ -358,7 +358,7 @@ var rootCmd = &cobra.Command{
// Handle sending to any other destination // Handle sending to any other destination
wireOut := api.FormatTextMessage(message) wireOut := api.FormatTextMessage(message)
fmt.Printf("Sending Message to %d, %v: %s\n", destinationUserId, globals.Log.INFO.Println("Sending Message to %d, %v: %s\n", destinationUserId,
recipientNick, message) recipientNick, message)
// Send the message // Send the message
...@@ -388,7 +388,7 @@ var rootCmd = &cobra.Command{ ...@@ -388,7 +388,7 @@ var rootCmd = &cobra.Command{
if ok { if ok {
contact = u.Nick contact = u.Nick
} }
fmt.Printf("Sending Message to %d, %v: %s\n", destinationUserId, globals.Log.INFO.Println("Sending Message to %d, %v: %s\n", destinationUserId,
contact, message) contact, message)
message := &parse.Message{ message := &parse.Message{
...@@ -414,7 +414,7 @@ var rootCmd = &cobra.Command{ ...@@ -414,7 +414,7 @@ var rootCmd = &cobra.Command{
err := client.Logout() err := client.Logout()
if err != nil { if err != nil {
fmt.Printf("Could not logout: %s\n", err.Error()) globals.Log.ERROR.Printf("Could not logout: %s\n", err.Error())
return return
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment