Skip to content

Commit

Permalink
Better logging
Browse files Browse the repository at this point in the history
  • Loading branch information
streamer45 committed Aug 15, 2024
1 parent d6af832 commit bd5066d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions client/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"io"
"log"
"log/slog"
"os"
"testing"
"time"
Expand Down Expand Up @@ -45,7 +46,7 @@ const (
userPass = "U$er-sample1"
teamName = "calls"
nChannels = 2
waitTimeout = 5 * time.Second
waitTimeout = 10 * time.Second
)

func (th *TestHelper) newScreenTrack(mimeType string) *webrtc.TrackLocalStaticRTP {
Expand Down Expand Up @@ -326,6 +327,11 @@ func setupTestHelper(tb testing.TB, channelName string) *TestHelper {
tb.Helper()
var err error

logger := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
AddSource: true,
Level: slog.LevelDebug,
}))

th := &TestHelper{
tb: tb,
channels: make(map[string]*model.Channel),
Expand Down Expand Up @@ -354,15 +360,15 @@ func setupTestHelper(tb testing.TB, channelName string) *TestHelper {
SiteURL: th.apiURL,
AuthToken: th.adminAPIClient.AuthToken,
ChannelID: channelID,
})
}, WithLogger(logger))
require.NoError(tb, err)
require.NotNil(tb, th.adminClient)

th.userClient, err = New(Config{
SiteURL: th.apiURL,
AuthToken: th.userAPIClient.AuthToken,
ChannelID: channelID,
})
}, WithLogger(logger))
require.NoError(tb, err)
require.NotNil(tb, th.userClient)

Expand Down
6 changes: 3 additions & 3 deletions client/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ func (c *Client) handleWSEventHello(ev *model.WebSocketEvent) (isReconnect bool,
}

if connID != c.currentConnID {
c.log.Debug("new connection id from server")
c.log.Debug("new connection id from server", slog.String("connID", connID))
}

if c.originalConnID == "" {
c.log.Debug("initial ws connection")
c.log.Debug("initial ws connection", slog.String("originalConnID", connID))
c.originalConnID = connID
} else {
c.log.Debug("ws reconnected successfully")
c.log.Debug("ws reconnected successfully", slog.String("originalConnID", c.originalConnID))
c.wsLastDisconnect = time.Time{}
c.wsReconnectInterval = 0
isReconnect = true
Expand Down

0 comments on commit bd5066d

Please sign in to comment.