From 3668db0eb6962c50d88f87d0d4a4f46cbb76a360 Mon Sep 17 00:00:00 2001 From: langhuihui <178529795@qq.com> Date: Thu, 19 Oct 2023 14:30:58 +0800 Subject: [PATCH] chore: add more log --- stream.go | 9 +++++++++ subscribers.go | 2 +- track/reader-av.go | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/stream.go b/stream.go index 187a4c0..8f2a77b 100644 --- a/stream.go +++ b/stream.go @@ -356,9 +356,18 @@ func (r *Stream) action(action StreamAction) (ok bool) { r.Subscribers.Dispose() r.actionChan.Close() } + if actionCoust := time.Since(event.Time); actionCoust > 100*time.Millisecond { + r.Warn("action timeout", zap.String("action", action.String()), zap.Duration("cost", actionCoust)) + } EventBus <- stateEvent + if actionCoust := time.Since(event.Time); actionCoust > 100*time.Millisecond { + r.Warn("action timeout after eventbus", zap.String("action", action.String()), zap.Duration("cost", actionCoust)) + } if r.Publisher != nil { r.Publisher.OnEvent(stateEvent) + if actionCoust := time.Since(event.Time); actionCoust > 100*time.Millisecond { + r.Warn("action timeout after send to publisher", zap.String("action", action.String()), zap.Duration("cost", actionCoust)) + } } } else { r.Debug("wrong action", zap.String("action", action.String())) diff --git a/subscribers.go b/subscribers.go index a8713e1..4c80d4d 100644 --- a/subscribers.go +++ b/subscribers.go @@ -126,7 +126,7 @@ func (s *Subscribers) Find(id string) ISubscriber { func (s *Subscribers) Delete(suber ISubscriber) { io := suber.GetSubscriber() for _, reader := range io.readers { - reader.Track.ReaderCount.Add(-1) + reader.Track.Debug("reader -1", zap.Int32("count", reader.Track.ReaderCount.Add(-1))) } if _, ok := s.public[suber]; ok { delete(s.public, suber) diff --git a/track/reader-av.go b/track/reader-av.go index 9de4cef..3e2befb 100644 --- a/track/reader-av.go +++ b/track/reader-av.go @@ -44,7 +44,7 @@ func (r *AVRingReader) DecConfChanged() bool { } func NewAVRingReader(t *Media) *AVRingReader { - t.ReaderCount.Add(1) + t.Debug("reader +1", zap.Int32("count", t.ReaderCount.Add(1))) return &AVRingReader{ Track: t, }