Logging adjustnments (#2273)

This commit is contained in:
Raja Subramanian
2023-11-29 15:40:01 +05:30
committed by GitHub
parent c4da7f5995
commit fa061b47fc
3 changed files with 20 additions and 15 deletions
+15 -8
View File
@@ -24,6 +24,7 @@ import (
"time" "time"
"go.uber.org/atomic" "go.uber.org/atomic"
"golang.org/x/exp/maps"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
"github.com/pion/sctp" "github.com/pion/sctp"
@@ -219,17 +220,21 @@ func (r *Room) GetParticipantByID(participantID livekit.ParticipantID) types.Loc
func (r *Room) GetParticipants() []types.LocalParticipant { func (r *Room) GetParticipants() []types.LocalParticipant {
r.lock.RLock() r.lock.RLock()
defer r.lock.RUnlock() defer r.lock.RUnlock()
participants := make([]types.LocalParticipant, 0, len(r.participants))
for _, p := range r.participants { return maps.Values(r.participants)
participants = append(participants, p)
}
return participants
} }
func (r *Room) GetLocalParticipants() []types.LocalParticipant { func (r *Room) GetLocalParticipants() []types.LocalParticipant {
return r.GetParticipants() 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 { func (r *Room) GetActiveSpeakers() []*livekit.SpeakerInfo {
participants := r.GetParticipants() participants := r.GetParticipants()
speakers := make([]*livekit.SpeakerInfo, 0, len(participants)) 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(), "pID", participant.ID(),
"participant", participant.Identity(), "participant", participant.Identity(),
"protocol", participant.ProtocolVersion(), "clientInfo", logger.Proto(participant.GetClientInfo()),
"options", opts) "options", opts,
"numParticipants", len(r.participants),
)
if participant.IsRecorder() && !r.protoRoom.ActiveRecording { if participant.IsRecorder() && !r.protoRoom.ActiveRecording {
r.protoRoom.ActiveRecording = true r.protoRoom.ActiveRecording = true
+1 -1
View File
@@ -55,7 +55,7 @@ func HandleParticipantSignal(room types.Room, participant types.LocalParticipant
participant.UpdateSubscribedTrackSettings(sid, msg.TrackSetting) participant.UpdateSubscribedTrackSettings(sid, msg.TrackSetting)
} }
case *livekit.SignalRequest_Leave: case *livekit.SignalRequest_Leave:
pLogger.Infow("client leaving room") pLogger.Debugw("client leaving room")
room.RemoveParticipant(participant.Identity(), participant.ID(), types.ParticipantCloseReasonClientRequestLeave) room.RemoveParticipant(participant.Identity(), participant.ID(), types.ParticipantCloseReasonClientRequestLeave)
case *livekit.SignalRequest_UpdateLayers: case *livekit.SignalRequest_UpdateLayers:
err := room.UpdateVideoLayers(participant, msg.UpdateLayers) err := room.UpdateVideoLayers(participant, msg.UpdateLayers)
+4 -6
View File
@@ -290,11 +290,10 @@ func (r *RoomManager) StartSession(
return errors.New("could not restart closed participant") return errors.New("could not restart closed participant")
} }
logger.Infow("resuming RTC session", participant.GetLogger().Infow("resuming RTC session",
"room", roomName,
"nodeID", r.currentNode.Id, "nodeID", r.currentNode.Id,
"participant", pi.Identity,
"reason", pi.ReconnectReason, "reason", pi.ReconnectReason,
"numParticipants", room.GetParticipantCount(),
) )
iceConfig := r.getIceConfig(participant) iceConfig := r.getIceConfig(participant)
if iceConfig == nil { if iceConfig == nil {
@@ -340,12 +339,11 @@ func (r *RoomManager) StartSession(
"room", roomName, "room", roomName,
"nodeID", r.currentNode.Id, "nodeID", r.currentNode.Id,
"participant", pi.Identity, "participant", pi.Identity,
"sdk", pi.Client.Sdk, "clientInfo", logger.Proto(pi.Client),
"sdkVersion", pi.Client.Version,
"protocol", pi.Client.Protocol,
"reconnect", pi.Reconnect, "reconnect", pi.Reconnect,
"reconnectReason", pi.ReconnectReason, "reconnectReason", pi.ReconnectReason,
"adaptiveStream", pi.AdaptiveStream, "adaptiveStream", pi.AdaptiveStream,
"numParticipants", room.GetParticipantCount(),
) )
clientConf := r.clientConfManager.GetConfiguration(pi.Client) clientConf := r.clientConfManager.GetConfiguration(pi.Client)