Log cleanup pass (#2285)
* Log cleanup pass Demoted a bunch of logs to DEBUG, consolidated logs. * use context logger and fix context var usage * moved common error types, fixed tests
This commit is contained in:
@@ -584,7 +584,6 @@ func (p *ParticipantImpl) HandleSignalSourceClose() {
|
||||
|
||||
if !p.TransportManager.HasPublisherEverConnected() && !p.TransportManager.HasSubscriberEverConnected() {
|
||||
reason := types.ParticipantCloseReasonJoinFailed
|
||||
p.params.Logger.Infow("closing disconnected participant", "reason", reason)
|
||||
_ = p.Close(false, reason, false)
|
||||
}
|
||||
}
|
||||
@@ -858,7 +857,7 @@ func (p *ParticipantImpl) MaybeStartMigration(force bool, onStart func()) bool {
|
||||
if p.IsClosed() || p.IsDisconnected() {
|
||||
return
|
||||
}
|
||||
p.subLogger.Infow("closing subscriber peer connection to aid migration")
|
||||
p.subLogger.Debugw("closing subscriber peer connection to aid migration")
|
||||
|
||||
//
|
||||
// Close all down tracks before closing subscriber peer connection.
|
||||
@@ -1444,7 +1443,6 @@ func (p *ParticipantImpl) setupDisconnectTimer() {
|
||||
return
|
||||
}
|
||||
reason := types.ParticipantCloseReasonPeerConnectionDisconnected
|
||||
p.params.Logger.Infow("closing disconnected participant", "reason", reason)
|
||||
_ = p.Close(true, reason, false)
|
||||
})
|
||||
p.lock.Unlock()
|
||||
@@ -1693,7 +1691,7 @@ func (p *ParticipantImpl) addPendingTrackLocked(req *livekit.AddTrackRequest) *l
|
||||
}
|
||||
|
||||
p.pendingTracks[req.Cid] = &pendingTrackInfo{trackInfos: []*livekit.TrackInfo{ti}}
|
||||
p.pubLogger.Infow("pending track added", "trackID", ti.Sid, "track", logger.Proto(ti), "request", logger.Proto(req))
|
||||
p.pubLogger.Debugw("pending track added", "trackID", ti.Sid, "track", logger.Proto(ti), "request", logger.Proto(req))
|
||||
return ti
|
||||
}
|
||||
|
||||
|
||||
@@ -289,7 +289,9 @@ func (p *ParticipantImpl) writeMessage(msg *livekit.SignalResponse) error {
|
||||
func (p *ParticipantImpl) CloseSignalConnection(reason types.SignallingCloseReason) {
|
||||
sink := p.getResponseSink()
|
||||
if sink != nil {
|
||||
p.params.Logger.Infow("closing signal connection", "reason", reason, "connID", sink.ConnectionID())
|
||||
if reason != types.SignallingCloseReasonParticipantClose {
|
||||
p.params.Logger.Infow("closing signal connection", "reason", reason, "connID", sink.ConnectionID())
|
||||
}
|
||||
sink.Close()
|
||||
p.SetResponseSink(nil)
|
||||
}
|
||||
|
||||
@@ -924,7 +924,7 @@ func (s *trackSubscription) handleSourceTrackRemoved() {
|
||||
}
|
||||
|
||||
// source track removed, we would unsubscribe
|
||||
s.logger.Infow("unsubscribing from track since source track was removed")
|
||||
s.logger.Debugw("unsubscribing from track since source track was removed")
|
||||
s.desired = false
|
||||
|
||||
s.setChangedNotifierLocked(nil)
|
||||
|
||||
+29
-24
@@ -466,10 +466,10 @@ func (t *PCTransport) setICEStartedAt(at time.Time) {
|
||||
} else if tcpICETimeout > maxTcpICEConnectTimeout {
|
||||
tcpICETimeout = maxTcpICEConnectTimeout
|
||||
}
|
||||
t.params.Logger.Debugw("set tcp ice connect timer", "timeout", tcpICETimeout, "signalRTT", signalingRTT)
|
||||
t.params.Logger.Debugw("set TCP ICE connect timer", "timeout", tcpICETimeout, "signalRTT", signalingRTT)
|
||||
t.tcpICETimer = time.AfterFunc(tcpICETimeout, func() {
|
||||
if t.pc.ICEConnectionState() == webrtc.ICEConnectionStateChecking {
|
||||
t.params.Logger.Infow("tcp ice connect timeout", "timeout", tcpICETimeout, "signalRTT", signalingRTT)
|
||||
t.params.Logger.Infow("TCP ICE connect timeout", "timeout", tcpICETimeout, "signalRTT", signalingRTT)
|
||||
t.handleConnectionFailed(true)
|
||||
}
|
||||
})
|
||||
@@ -497,7 +497,7 @@ func (t *PCTransport) setICEConnectedAt(at time.Time) {
|
||||
if connTimeoutAfterICE > maxConnectTimeoutAfterICE {
|
||||
connTimeoutAfterICE = maxConnectTimeoutAfterICE
|
||||
}
|
||||
t.params.Logger.Debugw("setting connection timer after ice connected", "timeout", connTimeoutAfterICE, "iceDuration", iceDuration)
|
||||
t.params.Logger.Debugw("setting connection timer after ICE connected", "timeout", connTimeoutAfterICE, "iceDuration", iceDuration)
|
||||
t.connectAfterICETimer = time.AfterFunc(connTimeoutAfterICE, func() {
|
||||
state := t.pc.ConnectionState()
|
||||
// if pc is still checking or connected but not fully established after timeout, then fire connection fail
|
||||
@@ -546,12 +546,12 @@ func (t *PCTransport) IsShortConnection(at time.Time) (bool, time.Duration) {
|
||||
}
|
||||
|
||||
func (t *PCTransport) getSelectedPair() (*webrtc.ICECandidatePair, error) {
|
||||
sctp := t.pc.SCTP()
|
||||
if sctp == nil {
|
||||
s := t.pc.SCTP()
|
||||
if s == nil {
|
||||
return nil, errors.New("no SCTP")
|
||||
}
|
||||
|
||||
dtlsTransport := sctp.Transport()
|
||||
dtlsTransport := s.Transport()
|
||||
if dtlsTransport == nil {
|
||||
return nil, errors.New("no DTLS transport")
|
||||
}
|
||||
@@ -629,11 +629,6 @@ func (t *PCTransport) onICEConnectionStateChange(state webrtc.ICEConnectionState
|
||||
switch state {
|
||||
case webrtc.ICEConnectionStateConnected:
|
||||
t.setICEConnectedAt(time.Now())
|
||||
if pair, err := t.getSelectedPair(); err != nil {
|
||||
t.params.Logger.Errorw("error getting selected ICE candidate pair", err)
|
||||
} else {
|
||||
t.params.Logger.Infow("selected ICE candidate pair", "pair", pair)
|
||||
}
|
||||
|
||||
case webrtc.ICEConnectionStateChecking:
|
||||
t.setICEStartedAt(time.Now())
|
||||
@@ -1268,7 +1263,7 @@ func (t *PCTransport) preparePC(previousAnswer webrtc.SessionDescription) error
|
||||
// trying to replicate previous setup, read from previous answer and use that role.
|
||||
//
|
||||
se := webrtc.SettingEngine{}
|
||||
se.SetAnsweringDTLSRole(lksdp.ExtractDTLSRole(parsed))
|
||||
_ = se.SetAnsweringDTLSRole(lksdp.ExtractDTLSRole(parsed))
|
||||
api := webrtc.NewAPI(
|
||||
webrtc.WithSettingEngine(se),
|
||||
webrtc.WithMediaEngine(t.me),
|
||||
@@ -1446,9 +1441,11 @@ func (t *PCTransport) processEvents() {
|
||||
|
||||
err := t.handleEvent(&event)
|
||||
if err != nil {
|
||||
t.params.Logger.Errorw("error handling event", err, "event", event.String())
|
||||
if onNegotiationFailed := t.getOnNegotiationFailed(); onNegotiationFailed != nil {
|
||||
onNegotiationFailed()
|
||||
if !t.isClosed.Load() {
|
||||
t.params.Logger.Errorw("error handling event", err, "event", event.String())
|
||||
if onNegotiationFailed := t.getOnNegotiationFailed(); onNegotiationFailed != nil {
|
||||
onNegotiationFailed()
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
@@ -1480,7 +1477,7 @@ func (t *PCTransport) handleEvent(e *event) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *PCTransport) handleICEGatheringComplete(e *event) error {
|
||||
func (t *PCTransport) handleICEGatheringComplete(_ *event) error {
|
||||
if t.params.IsOfferer {
|
||||
return t.handleICEGatheringCompleteOfferer()
|
||||
} else {
|
||||
@@ -1609,17 +1606,25 @@ func (t *PCTransport) handleRemoteICECandidate(e *event) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *PCTransport) handleLogICECandidates(e *event) error {
|
||||
func (t *PCTransport) handleLogICECandidates(_ *event) error {
|
||||
lc := t.allowedLocalCandidates.Get()
|
||||
rc := t.allowedRemoteCandidates.Get()
|
||||
var fields []interface{}
|
||||
if len(lc) != 0 || len(rc) != 0 {
|
||||
t.params.Logger.Infow(
|
||||
"ice candidates",
|
||||
fields = append(fields,
|
||||
"lc", lc,
|
||||
"rc", rc,
|
||||
"lc (filtered)", t.filteredLocalCandidates.Get(),
|
||||
"rc (filtered)", t.filteredRemoteCandidates.Get(),
|
||||
"lc_filtered", t.filteredLocalCandidates.Get(),
|
||||
"rc_filtered", t.filteredRemoteCandidates.Get(),
|
||||
)
|
||||
|
||||
}
|
||||
if pair, err := t.getSelectedPair(); err == nil {
|
||||
fields = append(fields, "selected_pair", pair)
|
||||
}
|
||||
|
||||
if len(fields) > 0 {
|
||||
t.params.Logger.Infow("ice candidates", fields...)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -1711,7 +1716,7 @@ func (t *PCTransport) createAndSendOffer(options *webrtc.OfferOptions) error {
|
||||
|
||||
// when there's an ongoing negotiation, let it finish and not disrupt its state
|
||||
if t.negotiationState == NegotiationStateRemote {
|
||||
t.params.Logger.Infow("skipping negotiation, trying again later")
|
||||
t.params.Logger.Debugw("skipping negotiation, trying again later")
|
||||
t.setNegotiationState(NegotiationStateRetry)
|
||||
return nil
|
||||
} else if t.negotiationState == NegotiationStateRetry {
|
||||
@@ -1801,7 +1806,7 @@ func (t *PCTransport) createAndSendOffer(options *webrtc.OfferOptions) error {
|
||||
return ErrNoOfferHandler
|
||||
}
|
||||
|
||||
func (t *PCTransport) handleSendOffer(e *event) error {
|
||||
func (t *PCTransport) handleSendOffer(_ *event) error {
|
||||
return t.createAndSendOffer(nil)
|
||||
}
|
||||
|
||||
@@ -2030,7 +2035,7 @@ func (t *PCTransport) doICERestart() error {
|
||||
}
|
||||
}
|
||||
|
||||
func (t *PCTransport) handleICERestart(e *event) error {
|
||||
func (t *PCTransport) handleICERestart(_ *event) error {
|
||||
return t.doICERestart()
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ func (u *UpTrackManager) SetPublishedTrackMuted(trackID livekit.TrackID, muted b
|
||||
track.SetMuted(muted)
|
||||
|
||||
if currentMuted != track.IsMuted() {
|
||||
u.params.Logger.Infow("publisher mute status changed", "trackID", trackID, "muted", track.IsMuted())
|
||||
u.params.Logger.Debugw("publisher mute status changed", "trackID", trackID, "muted", track.IsMuted())
|
||||
if u.onTrackUpdated != nil {
|
||||
u.onTrackUpdated(track)
|
||||
}
|
||||
@@ -142,7 +142,7 @@ func (u *UpTrackManager) GetPublishedTracks() []types.MediaTrack {
|
||||
func (u *UpTrackManager) UpdateSubscriptionPermission(
|
||||
subscriptionPermission *livekit.SubscriptionPermission,
|
||||
timedVersion utils.TimedVersion,
|
||||
resolverByIdentity func(participantIdentity livekit.ParticipantIdentity) types.LocalParticipant,
|
||||
_ func(participantIdentity livekit.ParticipantIdentity) types.LocalParticipant, // TODO: separate PR to remove this argument
|
||||
resolverBySid func(participantID livekit.ParticipantID) types.LocalParticipant,
|
||||
) error {
|
||||
u.lock.Lock()
|
||||
@@ -203,7 +203,7 @@ func (u *UpTrackManager) UpdateSubscriptionPermission(
|
||||
}
|
||||
u.lock.Unlock()
|
||||
|
||||
u.maybeRevokeSubscriptions(resolverByIdentity)
|
||||
u.maybeRevokeSubscriptions()
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -381,7 +381,7 @@ func (u *UpTrackManager) getAllowedSubscribersLocked(trackID livekit.TrackID) []
|
||||
return allowed
|
||||
}
|
||||
|
||||
func (u *UpTrackManager) maybeRevokeSubscriptions(resolver func(participantIdentity livekit.ParticipantIdentity) types.LocalParticipant) {
|
||||
func (u *UpTrackManager) maybeRevokeSubscriptions() {
|
||||
u.lock.Lock()
|
||||
defer u.lock.Unlock()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user