From 179f0054dacb2d603c59d19c020f0c3fd067cdb2 Mon Sep 17 00:00:00 2001
From: Jono Wenger <jono@elixxir.io>
Date: Mon, 18 Oct 2021 19:18:12 -0700
Subject: [PATCH] Add debug messages to group chat

---
 groupChat/makeGroup.go    | 4 ++++
 groupChat/manager.go      | 7 +++++++
 groupChat/send.go         | 3 +++
 groupChat/sendRequests.go | 3 +++
 4 files changed, 17 insertions(+)

diff --git a/groupChat/makeGroup.go b/groupChat/makeGroup.go
index fa230fadc..2c277b438 100644
--- a/groupChat/makeGroup.go
+++ b/groupChat/makeGroup.go
@@ -9,6 +9,7 @@ package groupChat
 
 import (
 	"github.com/pkg/errors"
+	jww "github.com/spf13/jwalterweatherman"
 	gs "gitlab.com/elixxir/client/groupChat/groupStore"
 	"gitlab.com/elixxir/crypto/contact"
 	"gitlab.com/elixxir/crypto/fastRNG"
@@ -79,6 +80,9 @@ func (m Manager) MakeGroup(membership []*id.ID, name, msg []byte) (gs.Group,
 		return gs.Group{}, nil, NotSent, errors.Errorf(addGroupErr, err)
 	}
 
+	jww.DEBUG.Printf("Created new group %q with ID %s and members %s",
+		g.Name, g.ID, g.Members)
+
 	// Send all group requests
 	roundIDs, status, err := m.sendRequests(g)
 
diff --git a/groupChat/manager.go b/groupChat/manager.go
index 2e2d18fad..6691e5415 100644
--- a/groupChat/manager.go
+++ b/groupChat/manager.go
@@ -9,6 +9,7 @@ package groupChat
 
 import (
 	"github.com/pkg/errors"
+	jww "github.com/spf13/jwalterweatherman"
 	"gitlab.com/elixxir/client/api"
 	gs "gitlab.com/elixxir/client/groupChat/groupStore"
 	"gitlab.com/elixxir/client/interfaces"
@@ -127,6 +128,8 @@ func (m Manager) JoinGroup(g gs.Group) error {
 		return errors.Errorf(joinGroupErr, g.ID, err)
 	}
 
+	jww.DEBUG.Printf("Joined group %s.", g.ID)
+
 	return nil
 }
 
@@ -136,17 +139,21 @@ func (m Manager) LeaveGroup(groupID *id.ID) error {
 		return errors.Errorf(leaveGroupErr, groupID, err)
 	}
 
+	jww.DEBUG.Printf("Left group %s.", groupID)
+
 	return nil
 }
 
 // GetGroups returns a list of all registered groupChat IDs.
 func (m Manager) GetGroups() []*id.ID {
+	jww.DEBUG.Print("Getting list of all groups.")
 	return m.gs.GroupIDs()
 }
 
 // GetGroup returns the group with the matching ID or returns false if none
 // exist.
 func (m Manager) GetGroup(groupID *id.ID) (gs.Group, bool) {
+	jww.DEBUG.Printf("Getting group with ID %s.", groupID)
 	return m.gs.Get(groupID)
 }
 
diff --git a/groupChat/send.go b/groupChat/send.go
index f2baa0953..cdb40888e 100644
--- a/groupChat/send.go
+++ b/groupChat/send.go
@@ -9,6 +9,7 @@ package groupChat
 
 import (
 	"github.com/pkg/errors"
+	jww "github.com/spf13/jwalterweatherman"
 	gs "gitlab.com/elixxir/client/groupChat/groupStore"
 	"gitlab.com/elixxir/client/interfaces/params"
 	"gitlab.com/elixxir/crypto/group"
@@ -48,6 +49,8 @@ func (m *Manager) Send(groupID *id.ID, message []byte) (id.Round, error) {
 		return 0, errors.Errorf(sendManyCmixErr, m.gs.GetUser().ID, groupID, err)
 	}
 
+	jww.DEBUG.Printf("Sent message to group %s.", groupID)
+
 	return rid, nil
 }
 
diff --git a/groupChat/sendRequests.go b/groupChat/sendRequests.go
index 70c5501ec..cd7913fcf 100644
--- a/groupChat/sendRequests.go
+++ b/groupChat/sendRequests.go
@@ -10,6 +10,7 @@ package groupChat
 import (
 	"github.com/golang/protobuf/proto"
 	"github.com/pkg/errors"
+	jww "github.com/spf13/jwalterweatherman"
 	gs "gitlab.com/elixxir/client/groupChat/groupStore"
 	"gitlab.com/elixxir/client/interfaces/message"
 	"gitlab.com/elixxir/client/interfaces/params"
@@ -34,6 +35,8 @@ func (m Manager) ResendRequest(groupID *id.ID) ([]id.Round, RequestStatus, error
 		return nil, NotSent, errors.Errorf(resendGroupIdErr, groupID)
 	}
 
+	jww.DEBUG.Printf("Resending group requests for group %s.", groupID)
+
 	return m.sendRequests(g)
 }
 
-- 
GitLab