From f49eadc0fb0c52907045cc5ef8a64d1c414c975a Mon Sep 17 00:00:00 2001
From: jaketaylor <jake@privategrity.com>
Date: Fri, 16 Aug 2019 15:50:12 -0700
Subject: [PATCH] fixed some various log messages around connection

---
 api/client.go | 18 ++++++++++--------
 cmd/root.go   |  3 ---
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/api/client.go b/api/client.go
index 50f157bbb..6aa8ed882 100644
--- a/api/client.go
+++ b/api/client.go
@@ -149,41 +149,43 @@ func NewClient(s globals.Storage, loc string, ndfJSON *ndf.NetworkDefinition) (*
 // using TLS filepaths to create credential information
 // for connection establishment
 func (cl *Client) Connect() error {
+	var err error
 	if len(cl.ndf.Gateways) < 1 {
-		globals.Log.ERROR.Printf("Connect: Invalid number of nodes")
 		return errors.New("could not connect due to invalid number of nodes")
 	}
 
-	//connect to all gateways
+	// connect to all gateways
 	for i, gateway := range cl.ndf.Gateways {
 		var gwCreds []byte
-		var err error
 		if gateway.TlsCertificate != "" {
 			gwCreds = []byte(gateway.TlsCertificate)
 		}
 		gwID := id.NewNodeFromBytes(cl.ndf.Nodes[i].ID).NewGateway()
+		globals.Log.INFO.Printf("Connecting to %s...", gateway.Address)
 		err = (cl.comm).(*io.Messaging).Comms.ConnectToGateway(gwID, gateway.Address, gwCreds)
 		if err != nil {
-			globals.Log.ERROR.Printf("Failed to connect to gateway %s: %+v", gateway.Address, err)
+			return errors.New(fmt.Sprintf("Failed to connect to gateway %s: %+v",
+				gateway.Address, err))
 		}
+		globals.Log.INFO.Printf("Connected to %v successfully!", gateway.Address)
 	}
 
 	//connect to the registration server
 	if cl.ndf.Registration.Address != "" {
 		var regCert []byte
-		var err error
 		if cl.ndf.Registration.TlsCertificate != "" {
 			regCert = []byte(cl.ndf.Registration.TlsCertificate)
 		}
 		addr := io.ConnAddr("registration")
 		err = (cl.comm).(*io.Messaging).Comms.ConnectToRegistration(addr, cl.ndf.Registration.Address, regCert)
 		if err != nil {
-			globals.Log.ERROR.Printf("Failed connecting to permissioning: %+v", err)
+			return errors.New(fmt.Sprintf(
+				"Failed connecting to permissioning: %+v", err))
 		}
 	} else {
-		globals.Log.WARN.Printf("Unable to find registration server")
+		globals.Log.WARN.Printf("Unable to find registration server!")
 	}
-	return nil
+	return err
 }
 
 // Registers user and returns the User ID.
diff --git a/cmd/root.go b/cmd/root.go
index 5391d302a..7b9f9ccf8 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -150,13 +150,10 @@ func sessionInitialization() (*id.User, string, *api.Client) {
 	}
 
 	// Connect to gateways and reg server
-	globals.Log.INFO.Println("Connecting...")
 	err = client.Connect()
-
 	if err != nil {
 		globals.Log.FATAL.Panicf("Could not call connect on client: %+v", err)
 	}
-	globals.Log.INFO.Println("Connected!")
 
 	// Holds the User ID
 	var uid *id.User
-- 
GitLab