From fa061b47fc7cc458c849ea9989ea7dac7e1da660 Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Wed, 29 Nov 2023 15:40:01 +0530 Subject: [PATCH] Logging adjustnments (#2273) --- pkg/rtc/room.go | 23 +++++++++++++++-------- pkg/rtc/signalhandler.go | 2 +- pkg/service/roommanager.go | 10 ++++------ 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/pkg/rtc/room.go b/pkg/rtc/room.go index e35fbc738..09904506f 100644 --- a/pkg/rtc/room.go +++ b/pkg/rtc/room.go @@ -24,6 +24,7 @@ import ( "time" "go.uber.org/atomic" + "golang.org/x/exp/maps" "google.golang.org/protobuf/proto" "github.com/pion/sctp" @@ -219,17 +220,21 @@ func (r *Room) GetParticipantByID(participantID livekit.ParticipantID) types.Loc func (r *Room) GetParticipants() []types.LocalParticipant { r.lock.RLock() defer r.lock.RUnlock() - participants := make([]types.LocalParticipant, 0, len(r.participants)) - for _, p := range r.participants { - participants = append(participants, p) - } - return participants + + return maps.Values(r.participants) } func (r *Room) GetLocalParticipants() []types.LocalParticipant { return r.GetParticipants() } +func (r *Room) GetParticipantCount() int { + r.lock.RLock() + defer r.lock.RUnlock() + + return len(r.participants) +} + func (r *Room) GetActiveSpeakers() []*livekit.SpeakerInfo { participants := r.GetParticipants() speakers := make([]*livekit.SpeakerInfo, 0, len(participants)) @@ -391,11 +396,13 @@ func (r *Room) Join(participant types.LocalParticipant, requestSource routing.Me } }) - r.Logger.Infow("new participant joined", + r.Logger.Debugw("new participant joined", "pID", participant.ID(), "participant", participant.Identity(), - "protocol", participant.ProtocolVersion(), - "options", opts) + "clientInfo", logger.Proto(participant.GetClientInfo()), + "options", opts, + "numParticipants", len(r.participants), + ) if participant.IsRecorder() && !r.protoRoom.ActiveRecording { r.protoRoom.ActiveRecording = true diff --git a/pkg/rtc/signalhandler.go b/pkg/rtc/signalhandler.go index 6f8ba407e..e835cf6ba 100644 --- a/pkg/rtc/signalhandler.go +++ b/pkg/rtc/signalhandler.go @@ -55,7 +55,7 @@ func HandleParticipantSignal(room types.Room, participant types.LocalParticipant participant.UpdateSubscribedTrackSettings(sid, msg.TrackSetting) } case *livekit.SignalRequest_Leave: - pLogger.Infow("client leaving room") + pLogger.Debugw("client leaving room") room.RemoveParticipant(participant.Identity(), participant.ID(), types.ParticipantCloseReasonClientRequestLeave) case *livekit.SignalRequest_UpdateLayers: err := room.UpdateVideoLayers(participant, msg.UpdateLayers) diff --git a/pkg/service/roommanager.go b/pkg/service/roommanager.go index d26eec0d5..a6fa679f3 100644 --- a/pkg/service/roommanager.go +++ b/pkg/service/roommanager.go @@ -290,11 +290,10 @@ func (r *RoomManager) StartSession( return errors.New("could not restart closed participant") } - logger.Infow("resuming RTC session", - "room", roomName, + participant.GetLogger().Infow("resuming RTC session", "nodeID", r.currentNode.Id, - "participant", pi.Identity, "reason", pi.ReconnectReason, + "numParticipants", room.GetParticipantCount(), ) iceConfig := r.getIceConfig(participant) if iceConfig == nil { @@ -340,12 +339,11 @@ func (r *RoomManager) StartSession( "room", roomName, "nodeID", r.currentNode.Id, "participant", pi.Identity, - "sdk", pi.Client.Sdk, - "sdkVersion", pi.Client.Version, - "protocol", pi.Client.Protocol, + "clientInfo", logger.Proto(pi.Client), "reconnect", pi.Reconnect, "reconnectReason", pi.ReconnectReason, "adaptiveStream", pi.AdaptiveStream, + "numParticipants", room.GetParticipantCount(), ) clientConf := r.clientConfManager.GetConfiguration(pi.Client)