Room logger with room name (#165)
* room with logger * participant with room logger * transport with room logger * simplify room logger usage * simplify logger * update protocol * more room logging, test fix
This commit is contained in:
+26
-23
@@ -42,6 +42,7 @@ type ParticipantParams struct {
|
||||
ThrottleConfig config.PLIThrottleConfig
|
||||
EnabledCodecs []*livekit.Codec
|
||||
Hidden bool
|
||||
Logger logger.Logger
|
||||
}
|
||||
|
||||
type ParticipantImpl struct {
|
||||
@@ -116,6 +117,7 @@ func NewParticipant(params ParticipantParams) (*ParticipantImpl, error) {
|
||||
Config: params.Config,
|
||||
Stats: p.params.Stats,
|
||||
EnabledCodecs: p.params.EnabledCodecs,
|
||||
Logger: params.Logger,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -124,6 +126,7 @@ func NewParticipant(params ParticipantParams) (*ParticipantImpl, error) {
|
||||
Target: livekit.SignalTarget_SUBSCRIBER,
|
||||
Config: params.Config,
|
||||
Stats: p.params.Stats,
|
||||
Logger: params.Logger,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -272,7 +275,7 @@ func (p *ParticipantImpl) OnClose(callback func(types.Participant)) {
|
||||
|
||||
// HandleOffer an offer from remote participant, used when clients make the initial connection
|
||||
func (p *ParticipantImpl) HandleOffer(sdp webrtc.SessionDescription) (answer webrtc.SessionDescription, err error) {
|
||||
logger.Debugw("answering pub offer", "state", p.State().String(),
|
||||
p.params.Logger.Debugw("answering pub offer", "state", p.State().String(),
|
||||
"participant", p.Identity(), "pID", p.ID(),
|
||||
//"sdp", sdp.SDP,
|
||||
)
|
||||
@@ -297,7 +300,7 @@ func (p *ParticipantImpl) HandleOffer(sdp webrtc.SessionDescription) (answer web
|
||||
return
|
||||
}
|
||||
|
||||
logger.Debugw("sending answer to client",
|
||||
p.params.Logger.Debugw("sending answer to client",
|
||||
"participant", p.Identity(), "pID", p.ID(),
|
||||
//"answer sdp", answer.SDP,
|
||||
)
|
||||
@@ -335,7 +338,7 @@ func (p *ParticipantImpl) AddTrack(req *livekit.AddTrackRequest) {
|
||||
}
|
||||
|
||||
if !p.CanPublish() {
|
||||
logger.Warnw("no permission to publish track", nil,
|
||||
p.params.Logger.Warnw("no permission to publish track", nil,
|
||||
"participant", p.Identity(), "pID", p.ID())
|
||||
return
|
||||
}
|
||||
@@ -368,7 +371,7 @@ func (p *ParticipantImpl) HandleAnswer(sdp webrtc.SessionDescription) error {
|
||||
if sdp.Type != webrtc.SDPTypeAnswer {
|
||||
return ErrUnexpectedOffer
|
||||
}
|
||||
logger.Debugw("setting subPC answer",
|
||||
p.params.Logger.Debugw("setting subPC answer",
|
||||
"participant", p.Identity(), "pID", p.ID(),
|
||||
//"sdp", sdp.SDP,
|
||||
)
|
||||
@@ -473,7 +476,7 @@ func (p *ParticipantImpl) AddSubscriber(op types.Participant) (int, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
logger.Debugw("subscribing new participant to tracks",
|
||||
p.params.Logger.Debugw("subscribing new participant to tracks",
|
||||
"participants", []string{p.Identity(), op.Identity()},
|
||||
"pIDs", []string{p.ID(), op.ID()},
|
||||
"numTracks", len(tracks))
|
||||
@@ -611,7 +614,7 @@ func (p *ParticipantImpl) SetTrackMuted(trackId string, muted bool, fromAdmin bo
|
||||
|
||||
if track == nil {
|
||||
if !isPending {
|
||||
logger.Warnw("could not locate track", nil, "track", trackId)
|
||||
p.params.Logger.Warnw("could not locate track", nil, "track", trackId)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -631,7 +634,7 @@ func (p *ParticipantImpl) SetTrackMuted(trackId string, muted bool, fromAdmin bo
|
||||
}
|
||||
|
||||
if currentMuted != track.IsMuted() && p.onTrackUpdated != nil {
|
||||
logger.Debugw("mute status changed",
|
||||
p.params.Logger.Debugw("mute status changed",
|
||||
"participant", p.Identity(),
|
||||
"pID", p.ID(),
|
||||
"track", trackId,
|
||||
@@ -715,7 +718,7 @@ func (p *ParticipantImpl) GetSubscribedTracks() []types.SubscribedTrack {
|
||||
|
||||
// AddSubscribedTrack adds a track to the participant's subscribed list
|
||||
func (p *ParticipantImpl) AddSubscribedTrack(pubId string, subTrack types.SubscribedTrack) {
|
||||
logger.Debugw("added subscribedTrack", "pIDs", []string{pubId, p.ID()},
|
||||
p.params.Logger.Debugw("added subscribedTrack", "pIDs", []string{pubId, p.ID()},
|
||||
"participant", p.Identity(), "track", subTrack.ID())
|
||||
p.lock.Lock()
|
||||
p.subscribedTracks[subTrack.ID()] = subTrack
|
||||
@@ -724,7 +727,7 @@ func (p *ParticipantImpl) AddSubscribedTrack(pubId string, subTrack types.Subscr
|
||||
|
||||
// RemoveSubscribedTrack removes a track to the participant's subscribed list
|
||||
func (p *ParticipantImpl) RemoveSubscribedTrack(pubId string, subTrack types.SubscribedTrack) {
|
||||
logger.Debugw("removed subscribedTrack", "pIDs", []string{pubId, p.ID()},
|
||||
p.params.Logger.Debugw("removed subscribedTrack", "pIDs", []string{pubId, p.ID()},
|
||||
"participant", p.Identity(), "track", subTrack.ID())
|
||||
p.lock.Lock()
|
||||
delete(p.subscribedTracks, subTrack.ID())
|
||||
@@ -735,7 +738,7 @@ func (p *ParticipantImpl) sendIceCandidate(c *webrtc.ICECandidate, target liveki
|
||||
ci := c.ToJSON()
|
||||
|
||||
// write candidate
|
||||
logger.Debugw("sending ice candidates",
|
||||
p.params.Logger.Debugw("sending ice candidates",
|
||||
"participant", p.Identity(),
|
||||
"pID", p.ID(),
|
||||
"candidate", c.String())
|
||||
@@ -754,7 +757,7 @@ func (p *ParticipantImpl) updateState(state livekit.ParticipantInfo_State) {
|
||||
return
|
||||
}
|
||||
p.state.Store(state)
|
||||
logger.Debugw("updating participant state", "state", state.String(), "participant", p.Identity(), "pID", p.ID())
|
||||
p.params.Logger.Debugw("updating participant state", "state", state.String(), "participant", p.Identity(), "pID", p.ID())
|
||||
p.lock.RLock()
|
||||
onStateChange := p.onStateChange
|
||||
p.lock.RUnlock()
|
||||
@@ -776,7 +779,7 @@ func (p *ParticipantImpl) writeMessage(msg *livekit.SignalResponse) error {
|
||||
}
|
||||
err := sink.WriteMessage(msg)
|
||||
if err != nil {
|
||||
logger.Warnw("could not send message to participant", err,
|
||||
p.params.Logger.Warnw("could not send message to participant", err,
|
||||
"pID", p.ID(),
|
||||
"participant", p.Identity(),
|
||||
"message", fmt.Sprintf("%T", msg.Message))
|
||||
@@ -788,12 +791,12 @@ func (p *ParticipantImpl) writeMessage(msg *livekit.SignalResponse) error {
|
||||
// when the server has an offer for participant
|
||||
func (p *ParticipantImpl) onOffer(offer webrtc.SessionDescription) {
|
||||
if p.State() == livekit.ParticipantInfo_DISCONNECTED {
|
||||
logger.Debugw("skipping server offer", "participant", p.Identity(), "pID", p.ID())
|
||||
p.params.Logger.Debugw("skipping server offer", "participant", p.Identity(), "pID", p.ID())
|
||||
// skip when disconnected
|
||||
return
|
||||
}
|
||||
|
||||
logger.Debugw("sending server offer to participant",
|
||||
p.params.Logger.Debugw("sending server offer to participant",
|
||||
"participant", p.Identity(), "pID", p.ID(),
|
||||
//"sdp", offer.SDP,
|
||||
)
|
||||
@@ -816,7 +819,7 @@ func (p *ParticipantImpl) onMediaTrack(track *webrtc.TrackRemote, rtpReceiver *w
|
||||
return
|
||||
}
|
||||
|
||||
logger.Debugw("mediaTrack added",
|
||||
p.params.Logger.Debugw("mediaTrack added",
|
||||
"kind", track.Kind().String(),
|
||||
"participant", p.Identity(),
|
||||
"pID", p.ID(),
|
||||
@@ -825,7 +828,7 @@ func (p *ParticipantImpl) onMediaTrack(track *webrtc.TrackRemote, rtpReceiver *w
|
||||
"SSRC", track.SSRC())
|
||||
|
||||
if !p.CanPublish() {
|
||||
logger.Warnw("no permission to publish mediaTrack", nil,
|
||||
p.params.Logger.Warnw("no permission to publish mediaTrack", nil,
|
||||
"participant", p.Identity(), "pID", p.ID())
|
||||
return
|
||||
}
|
||||
@@ -895,7 +898,7 @@ func (p *ParticipantImpl) onDataChannel(dc *webrtc.DataChannel) {
|
||||
p.handleDataMessage(livekit.DataPacket_LOSSY, msg.Data)
|
||||
})
|
||||
default:
|
||||
logger.Warnw("unsupported datachannel added", nil, "participant", p.Identity(), "pID", p.ID(), "label", dc.Label())
|
||||
p.params.Logger.Warnw("unsupported datachannel added", nil, "participant", p.Identity(), "pID", p.ID(), "label", dc.Label())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -940,7 +943,7 @@ func (p *ParticipantImpl) getPendingTrack(clientId string, kind livekit.TrackTyp
|
||||
|
||||
// if still not found, we are done
|
||||
if ti == nil {
|
||||
logger.Errorw("track info not published prior to track", nil, "clientId", clientId)
|
||||
p.params.Logger.Errorw("track info not published prior to track", nil, "clientId", clientId)
|
||||
}
|
||||
return signalCid, ti
|
||||
}
|
||||
@@ -948,7 +951,7 @@ func (p *ParticipantImpl) getPendingTrack(clientId string, kind livekit.TrackTyp
|
||||
func (p *ParticipantImpl) handleDataMessage(kind livekit.DataPacket_Kind, data []byte) {
|
||||
dp := livekit.DataPacket{}
|
||||
if err := proto.Unmarshal(data, &dp); err != nil {
|
||||
logger.Warnw("could not parse data packet", err)
|
||||
p.params.Logger.Warnw("could not parse data packet", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -963,7 +966,7 @@ func (p *ParticipantImpl) handleDataMessage(kind livekit.DataPacket_Kind, data [
|
||||
p.onDataPacket(p, &dp)
|
||||
}
|
||||
default:
|
||||
logger.Warnw("received unsupported data packet", nil, "payload", payload)
|
||||
p.params.Logger.Warnw("received unsupported data packet", nil, "payload", payload)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -994,7 +997,7 @@ func (p *ParticipantImpl) handleTrackPublished(track types.PublishedTrack) {
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) handlePrimaryICEStateChange(state webrtc.ICEConnectionState) {
|
||||
// logger.Debugw("ICE connection state changed", "state", state.String(),
|
||||
// p.params.Logger.Debugw("ICE connection state changed", "state", state.String(),
|
||||
// "participant", p.identity, "pID", p.ID())
|
||||
if state == webrtc.ICEConnectionStateConnected {
|
||||
stats.PromServiceOperationCounter.WithLabelValues("ice_connection", "success", "").Add(1)
|
||||
@@ -1102,7 +1105,7 @@ func (p *ParticipantImpl) rtcpSendWorker() {
|
||||
|
||||
if len(fwdPkts) > 0 {
|
||||
if err := p.publisher.pc.WriteRTCP(fwdPkts); err != nil {
|
||||
logger.Errorw("could not write RTCP to participant", err,
|
||||
p.params.Logger.Errorw("could not write RTCP to participant", err,
|
||||
"participant", p.Identity(), "pID", p.ID())
|
||||
}
|
||||
}
|
||||
@@ -1206,7 +1209,7 @@ func (p *ParticipantImpl) configureReceiverDTX() {
|
||||
|
||||
err := transceiver.SetCodecPreferences(append(modifiedReceiverCodecs, senderCodecs...))
|
||||
if err != nil {
|
||||
logger.Warnw("failed to SetCodecPreferences", err)
|
||||
p.params.Logger.Warnw("failed to SetCodecPreferences", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user