Cleanup pass through logging (#1073)

* added filtering for noisy pion logs
* demoted some logs to debug
* using consistent trackID / participant / publisher / subscriber terminology
* removed ice candidate log lines, deferring to combined log
This commit is contained in:
David Zhao
2022-10-06 23:48:37 -07:00
committed by GitHub
parent 792349cc56
commit 1019faa0e6
16 changed files with 114 additions and 55 deletions
+22 -15
View File
@@ -530,7 +530,6 @@ func (p *ParticipantImpl) setCodecPreferencesVideoForPublisher(offer webrtc.Sess
bytes, err := parsed.Marshal()
if err != nil {
p.params.Logger.Infow("failed to marshal offer", "error", err)
p.params.Logger.Errorw("failed to marshal offer", err)
return offer
}
@@ -646,7 +645,7 @@ func (p *ParticipantImpl) Start() {
}
func (p *ParticipantImpl) Close(sendLeave bool, reason types.ParticipantCloseReason) error {
p.params.Logger.Infow("try close participant", "sendLeave", sendLeave, "reason", reason.String())
p.params.Logger.Infow("participant closing", "sendLeave", sendLeave, "reason", reason.String())
if p.isClosed.Swap(true) {
// already closed
return nil
@@ -755,6 +754,7 @@ func (p *ParticipantImpl) MaybeStartMigration(force bool, onStart func()) bool {
if p.isClosed.Load() || p.State() == livekit.ParticipantInfo_DISCONNECTED {
return
}
// TODO: change to debug once we are confident
p.params.Logger.Infow("closing subscriber peer connection to aid migration")
//
@@ -968,16 +968,20 @@ func (p *ParticipantImpl) UpdateSubscribedTrackSettings(trackID livekit.TrackID,
// AddSubscribedTrack adds a track to the participant's subscribed list
func (p *ParticipantImpl) AddSubscribedTrack(subTrack types.SubscribedTrack) {
p.lock.Lock()
if v, ok := p.trackPublisherVersion[subTrack.ID()]; ok && v > subTrack.PublisherVersion() {
p.lock.Unlock()
p.params.Logger.Infow("ignoring add subscribedTrack from older version",
"current", v,
"requesting", subTrack.PublisherVersion(),
"trackID", subTrack.ID(),
)
return
}
p.params.Logger.Infow("added subscribedTrack",
"publisherID", subTrack.PublisherID(),
"publisherIdentity", subTrack.PublisherIdentity(),
"trackID", subTrack.ID())
p.lock.Lock()
if v, ok := p.trackPublisherVersion[subTrack.ID()]; ok && v > subTrack.PublisherVersion() {
p.lock.Unlock()
p.params.Logger.Infow("ignoring add subscribedTrack from older version", "current", v, "requesting", subTrack.PublisherVersion())
return
}
p.trackPublisherVersion[subTrack.ID()] = subTrack.PublisherVersion()
onSubscribedTo := p.onSubscribedTo
@@ -1011,17 +1015,20 @@ func (p *ParticipantImpl) AddSubscribedTrack(subTrack types.SubscribedTrack) {
// RemoveSubscribedTrack removes a track to the participant's subscribed list
func (p *ParticipantImpl) RemoveSubscribedTrack(subTrack types.SubscribedTrack) {
p.lock.Lock()
if v, ok := p.trackPublisherVersion[subTrack.ID()]; ok && v > subTrack.PublisherVersion() {
p.lock.Unlock()
p.params.Logger.Infow("ignoring remove subscribedTrack from older version",
"current", v,
"requesting", subTrack.PublisherVersion(),
"trackID", subTrack.ID(),
)
return
}
p.params.Logger.Infow("removed subscribedTrack",
"publisherID", subTrack.PublisherID(),
"publisherIdentity", subTrack.PublisherIdentity(),
"trackID", subTrack.ID(), "kind", subTrack.DownTrack().Kind())
p.lock.Lock()
if v, ok := p.trackPublisherVersion[subTrack.ID()]; ok && v > subTrack.PublisherVersion() {
p.lock.Unlock()
p.params.Logger.Infow("ignoring remove subscribedTrack from older version", "current", v, "requesting", subTrack.PublisherVersion())
return
}
p.trackPublisherVersion[subTrack.ID()] = subTrack.PublisherVersion()
delete(p.subscribedTracks, subTrack.ID())
-1
View File
@@ -139,7 +139,6 @@ func (p *ParticipantImpl) SendRefreshToken(token string) error {
}
func (p *ParticipantImpl) sendICECandidate(c *webrtc.ICECandidate, target livekit.SignalTarget) error {
p.params.Logger.Infow("sending ice candidate", "candidate", c.String(), "target", target)
trickle := ToProtoTrickle(c.ToJSON())
trickle.Target = target
return p.writeMessage(&livekit.SignalResponse{
+15 -8
View File
@@ -718,13 +718,17 @@ func (r *Room) onTrackPublished(participant types.LocalParticipant, track types.
}
r.Logger.Debugw("subscribing to new track",
"participants", []livekit.ParticipantIdentity{participant.Identity(), existingParticipant.Identity()},
"pIDs", []livekit.ParticipantID{participant.ID(), existingParticipant.ID()},
"participant", existingParticipant.Identity(),
"pID", existingParticipant.ID(),
"publisher", participant.Identity(),
"publisherID", participant.ID(),
"trackID", track.ID())
if _, err := participant.AddSubscriber(existingParticipant, types.AddSubscriberParams{TrackIDs: []livekit.TrackID{track.ID()}}); err != nil {
r.Logger.Errorw("could not subscribe to remoteTrack", err,
"participants", []livekit.ParticipantIdentity{participant.Identity(), existingParticipant.Identity()},
"pIDs", []livekit.ParticipantID{participant.ID(), existingParticipant.ID()},
"participant", existingParticipant.Identity(),
"pID", existingParticipant.ID(),
"publisher", participant.Identity(),
"publisherID", participant.ID(),
"trackID", track.ID())
}
}
@@ -814,14 +818,17 @@ func (r *Room) subscribeToExistingTracks(p types.LocalParticipant) int {
n, err := op.AddSubscriber(p, types.AddSubscriberParams{AllTracks: true})
if err != nil {
// TODO: log error? or disconnect?
r.Logger.Errorw("could not subscribe to participant", err,
"participants", []livekit.ParticipantIdentity{op.Identity(), p.Identity()},
"pIDs", []livekit.ParticipantID{op.ID(), p.ID()})
r.Logger.Errorw("could not subscribe to publisher", err,
"participant", p.Identity(),
"pID", p.ID(),
"publisher", op.Identity(),
"publisherID", op.ID(),
)
}
tracksAdded += n
}
if tracksAdded > 0 {
r.Logger.Debugw("subscribed participants to existing tracks", "tracks", tracksAdded)
r.Logger.Debugw("subscribed participants to existing tracks", "trackID", tracksAdded)
}
return tracksAdded
}
+2 -2
View File
@@ -43,11 +43,11 @@ func HandleParticipantSignal(room types.Room, participant types.LocalParticipant
}
if err != nil {
pLogger.Warnw("could not update subscription", err,
"tracks", msg.Subscription.TrackSids,
"trackID", msg.Subscription.TrackSids,
"subscribe", msg.Subscription.Subscribe)
} else {
pLogger.Infow("updated subscription",
"tracks", msg.Subscription.TrackSids,
"trackID", msg.Subscription.TrackSids,
"subscribe", msg.Subscription.Subscribe)
}
case *livekit.SignalRequest_TrackSetting:
+10 -10
View File
@@ -496,6 +496,7 @@ func (t *PCTransport) onPeerConnectionStateChange(state webrtc.PeerConnectionSta
t.maybeNotifyFullyEstablished()
}
case webrtc.PeerConnectionStateFailed:
t.logICECandidates()
t.handleConnectionFailed()
}
}
@@ -1297,7 +1298,7 @@ func (t *PCTransport) processEvents() {
}
t.clearSignalStateCheckTimer()
t.params.Logger.Infow("leaving events processor")
t.params.Logger.Debugw("leaving events processor")
}
func (t *PCTransport) handleEvent(e *event) error {
@@ -1396,7 +1397,7 @@ func (t *PCTransport) handleLocalICECandidate(e *event) error {
filtered := false
if t.preferTCP.Load() && c != nil && c.Protocol != webrtc.ICEProtocolTCP {
cstr := c.String()
t.params.Logger.Infow("filtering out local candidate", "candidate", cstr)
t.params.Logger.Debugw("filtering out local candidate", "candidate", cstr)
t.filteredLocalCandidates = append(t.filteredLocalCandidates, cstr)
filtered = true
}
@@ -1425,7 +1426,7 @@ func (t *PCTransport) handleRemoteICECandidate(e *event) error {
filtered := false
if t.preferTCP.Load() && !strings.Contains(c.Candidate, "tcp") {
t.params.Logger.Infow("filtering out remote candidate", "candidate", c.Candidate)
t.params.Logger.Debugw("filtering out remote candidate", "candidate", c.Candidate)
t.filteredRemoteCandidates = append(t.filteredRemoteCandidates, c.Candidate)
filtered = true
}
@@ -1443,7 +1444,6 @@ func (t *PCTransport) handleRemoteICECandidate(e *event) error {
return nil
}
t.params.Logger.Infow("add candidate ", "candidate", c.Candidate)
if err := t.pc.AddICECandidate(*c); err != nil {
return errors.Wrap(err, "add ice candidate failed")
}
@@ -1584,7 +1584,7 @@ func (t *PCTransport) createAndSendOffer(options *webrtc.OfferOptions) error {
preferTCP := t.preferTCP.Load()
if preferTCP {
t.params.Logger.Infow("local offer (unfiltered)", "sdp", offer.SDP)
t.params.Logger.Debugw("local offer (unfiltered)", "sdp", offer.SDP)
}
err = t.pc.SetLocalDescription(offer)
@@ -1601,7 +1601,7 @@ func (t *PCTransport) createAndSendOffer(options *webrtc.OfferOptions) error {
//
offer = t.filterCandidates(offer, preferTCP)
if preferTCP {
t.params.Logger.Infow("local offer (filtered)", "sdp", offer.SDP)
t.params.Logger.Debugw("local offer (filtered)", "sdp", offer.SDP)
}
// indicate waiting for remote
@@ -1655,11 +1655,11 @@ func (t *PCTransport) setRemoteDescription(sd webrtc.SessionDescription) error {
// filter before setting remote description so that pion does not see filtered remote candidates
preferTCP := t.preferTCP.Load()
if preferTCP {
t.params.Logger.Infow("remote description (unfiltered)", "type", sd.Type, "sdp", sd.SDP)
t.params.Logger.Debugw("remote description (unfiltered)", "type", sd.Type, "sdp", sd.SDP)
}
sd = t.filterCandidates(sd, preferTCP)
if preferTCP {
t.params.Logger.Infow("remote description (filtered)", "type", sd.Type, "sdp", sd.SDP)
t.params.Logger.Debugw("remote description (filtered)", "type", sd.Type, "sdp", sd.SDP)
}
if err := t.pc.SetRemoteDescription(sd); err != nil {
@@ -1703,7 +1703,7 @@ func (t *PCTransport) createAndSendAnswer() error {
preferTCP := t.preferTCP.Load()
if preferTCP {
t.params.Logger.Infow("local answer (unfiltered)", "sdp", answer.SDP)
t.params.Logger.Debugw("local answer (unfiltered)", "sdp", answer.SDP)
}
if err = t.pc.SetLocalDescription(answer); err != nil {
@@ -1719,7 +1719,7 @@ func (t *PCTransport) createAndSendAnswer() error {
//
answer = t.filterCandidates(answer, preferTCP)
if preferTCP {
t.params.Logger.Infow("local answer (filtered)", "sdp", answer.SDP)
t.params.Logger.Debugw("local answer (filtered)", "sdp", answer.SDP)
}
if onAnswer := t.getOnAnswer(); onAnswer != nil {
+1 -1
View File
@@ -169,7 +169,7 @@ func (u *UpTrackManager) SetPublishedTrackMuted(trackID livekit.TrackID, muted b
track.SetMuted(muted)
if currentMuted != track.IsMuted() {
u.params.Logger.Infow("mute status changed", "trackID", trackID, "muted", track.IsMuted())
u.params.Logger.Infow("publisher mute status changed", "trackID", trackID, "muted", track.IsMuted())
if u.onTrackUpdated != nil {
u.onTrackUpdated(track, false)
}