clean up logs and imports (#400)

This commit is contained in:
David Colburn
2022-02-03 14:20:19 -07:00
committed by GitHub
parent 7297a57f3d
commit 7bbd238188
24 changed files with 44 additions and 40 deletions
+1 -1
View File
@@ -3,12 +3,12 @@ package serverlogger
import ( import (
"github.com/go-logr/logr" "github.com/go-logr/logr"
"github.com/go-logr/zapr" "github.com/go-logr/zapr"
"github.com/livekit/protocol/logger"
"github.com/pion/logging" "github.com/pion/logging"
"go.uber.org/zap" "go.uber.org/zap"
"go.uber.org/zap/zapcore" "go.uber.org/zap/zapcore"
"github.com/livekit/livekit-server/pkg/config" "github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/protocol/logger"
) )
var ( var (
+2 -2
View File
@@ -83,12 +83,12 @@ func (s *RegionAwareSelector) SelectNode(nodes []*livekit.Node) (*livekit.Node,
return nodes[idx], nil return nodes[idx], nil
} }
// haversin(θ) function // haversine(θ) function
func hsin(theta float64) float64 { func hsin(theta float64) float64 {
return math.Pow(math.Sin(theta/2), 2) return math.Pow(math.Sin(theta/2), 2)
} }
// Haversin Distance Formula // Haversine Distance Formula
// http://en.wikipedia.org/wiki/Haversine_formula // http://en.wikipedia.org/wiki/Haversine_formula
// from https://gist.github.com/cdipaolo/d3f8db3848278b49db68 // from https://gist.github.com/cdipaolo/d3f8db3848278b49db68
func distanceBetween(lat1, lon1, lat2, lon2 float64) float64 { func distanceBetween(lat1, lon1, lat2, lon2 float64) float64 {
+1 -1
View File
@@ -184,7 +184,7 @@ func (t *MediaTrackSubscriptions) AddSubscriber(sub types.LocalParticipant, code
downTrack.SetTransceiver(transceiver) downTrack.SetTransceiver(transceiver)
// when outtrack is bound, start loop to send reports // when out track is bound, start loop to send reports
downTrack.OnBind(func() { downTrack.OnBind(func() {
go subTrack.Bound() go subTrack.Bound()
go t.sendDownTrackBindingReports(sub) go t.sendDownTrackBindingReports(sub)
+3 -4
View File
@@ -8,11 +8,8 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/livekit/livekit-server/pkg/sfu/connectionquality"
"github.com/livekit/livekit-server/pkg/sfu/twcc"
"github.com/livekit/protocol/auth"
lru "github.com/hashicorp/golang-lru" lru "github.com/hashicorp/golang-lru"
"github.com/livekit/protocol/auth"
"github.com/livekit/protocol/livekit" "github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger" "github.com/livekit/protocol/logger"
"github.com/livekit/protocol/utils" "github.com/livekit/protocol/utils"
@@ -25,6 +22,8 @@ import (
"github.com/livekit/livekit-server/pkg/routing" "github.com/livekit/livekit-server/pkg/routing"
"github.com/livekit/livekit-server/pkg/rtc/types" "github.com/livekit/livekit-server/pkg/rtc/types"
"github.com/livekit/livekit-server/pkg/sfu" "github.com/livekit/livekit-server/pkg/sfu"
"github.com/livekit/livekit-server/pkg/sfu/connectionquality"
"github.com/livekit/livekit-server/pkg/sfu/twcc"
"github.com/livekit/livekit-server/pkg/telemetry" "github.com/livekit/livekit-server/pkg/telemetry"
"github.com/livekit/livekit-server/pkg/telemetry/prometheus" "github.com/livekit/livekit-server/pkg/telemetry/prometheus"
"github.com/livekit/livekit-server/version" "github.com/livekit/livekit-server/version"
+3 -3
View File
@@ -93,9 +93,9 @@ func newPeerConnection(params TransportParams, onBandwidthEstimator func(estimat
// Disable SRTP replay protection (https://datatracker.ietf.org/doc/html/rfc3711#page-15). // Disable SRTP replay protection (https://datatracker.ietf.org/doc/html/rfc3711#page-15).
// Needed due to lack of RTX stream support in Pion. // Needed due to lack of RTX stream support in Pion.
// //
// When clients probe for bandwidth, there are sveral possible approaches // When clients probe for bandwidth, there are several possible approaches
// 1. Use padding packet (Chrome uses this) // 1. Use padding packet (Chrome uses this)
// 2. Use an older packet (Forefox uses this) // 2. Use an older packet (Firefox uses this)
// Typically, these are sent over the RTX stream and hence SRTP replay protection will not // Typically, these are sent over the RTX stream and hence SRTP replay protection will not
// trigger. As Pion does not support RTX, when firefox uses older packet for probing, they // trigger. As Pion does not support RTX, when firefox uses older packet for probing, they
// trigger the replay protection. // trigger the replay protection.
@@ -113,7 +113,7 @@ func newPeerConnection(params TransportParams, onBandwidthEstimator func(estimat
} }
// //
// This introduces a half-RTT extra latency in connection setup, // This introduces a half-RTT extra latency in connection setup,
// i. e. if SFU is acting as DTLSRoleClient, it can send the client-hello as soon // i.e. if SFU is acting as DTLSRoleClient, it can send the client-hello as soon
// as it is ready. With this change, signalling has to be sent back to the client // as it is ready. With this change, signalling has to be sent back to the client
// and client has to do client-hello which adds half RTT. // and client has to do client-hello which adds half RTT.
// //
+4 -4
View File
@@ -151,13 +151,13 @@ func (b *Buffer) Bind(params webrtc.RTPParameters, codec webrtc.RTPCodecCapabili
for _, fb := range codec.RTCPFeedback { for _, fb := range codec.RTCPFeedback {
switch fb.Type { switch fb.Type {
case webrtc.TypeRTCPFBGoogREMB: case webrtc.TypeRTCPFBGoogREMB:
b.logger.Infow("Setting feedback", "type", webrtc.TypeRTCPFBGoogREMB) b.logger.Debugw("Setting feedback", "type", webrtc.TypeRTCPFBGoogREMB)
b.remb = true b.remb = true
case webrtc.TypeRTCPFBTransportCC: case webrtc.TypeRTCPFBTransportCC:
b.logger.Infow("Setting feedback", "type", webrtc.TypeRTCPFBTransportCC) b.logger.Debugw("Setting feedback", "type", webrtc.TypeRTCPFBTransportCC)
b.twcc = true b.twcc = true
case webrtc.TypeRTCPFBNACK: case webrtc.TypeRTCPFBNACK:
b.logger.Infow("Setting feedback", "type", webrtc.TypeRTCPFBNACK) b.logger.Debugw("Setting feedback", "type", webrtc.TypeRTCPFBNACK)
b.nacker = NewNACKQueue() b.nacker = NewNACKQueue()
b.nack = true b.nack = true
} }
@@ -177,7 +177,7 @@ func (b *Buffer) Bind(params webrtc.RTPParameters, codec webrtc.RTPCodecCapabili
b.pPackets = nil b.pPackets = nil
b.bound = true b.bound = true
b.logger.Infow("NewBuffer", "MaxBitRate", o.MaxBitRate) b.logger.Debugw("NewBuffer", "MaxBitRate", o.MaxBitRate)
} }
// Write adds an RTP Packet, out of order, new packet may be arrived later // Write adds an RTP Packet, out of order, new packet may be arrived later
+1 -1
View File
@@ -269,7 +269,7 @@ func IsH264Keyframe(payload []byte) bool {
return true return true
} else if n >= 24 { } else if n >= 24 {
// is this legal? // is this legal?
logger.Infow("Non-simple NALU within a STAP") logger.Debugw("Non-simple NALU within a STAP")
} }
i += int(length) i += int(length)
} }
+1 -1
View File
@@ -493,7 +493,7 @@ func (d *DownTrack) CloseWithFlush(flush bool) {
} }
d.closeOnce.Do(func() { d.closeOnce.Do(func() {
d.logger.Infow("closing sender", "peerID", d.peerID, "trackID", d.id, "kind", d.kind) d.logger.Debugw("closing sender", "peerID", d.peerID, "trackID", d.id, "kind", d.kind)
d.receiver.DeleteDownTrack(d.peerID) d.receiver.DeleteDownTrack(d.peerID)
d.connectionStats.Close() d.connectionStats.Close()
+1 -1
View File
@@ -6,10 +6,10 @@ import (
"strings" "strings"
"sync" "sync"
"github.com/livekit/protocol/logger"
"github.com/pion/webrtc/v3" "github.com/pion/webrtc/v3"
"github.com/livekit/livekit-server/pkg/sfu/buffer" "github.com/livekit/livekit-server/pkg/sfu/buffer"
"github.com/livekit/protocol/logger"
) )
// //
+1 -1
View File
@@ -4,12 +4,12 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/livekit/protocol/logger"
"github.com/pion/webrtc/v3" "github.com/pion/webrtc/v3"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/livekit/livekit-server/pkg/sfu/buffer" "github.com/livekit/livekit-server/pkg/sfu/buffer"
"github.com/livekit/livekit-server/pkg/sfu/testutils" "github.com/livekit/livekit-server/pkg/sfu/testutils"
"github.com/livekit/protocol/logger"
) )
func disable(f *Forwarder) { func disable(f *Forwarder) {
+3 -3
View File
@@ -348,9 +348,9 @@ func (w *WebRTCReceiver) GetTotalBytes() uint64 {
defer w.bufferMu.RUnlock() defer w.bufferMu.RUnlock()
totalBytes := uint64(0) totalBytes := uint64(0)
for _, buffer := range w.buffers { for _, buff := range w.buffers {
if buffer != nil { if buff != nil {
stats := buffer.GetStats() stats := buff.GetStats()
totalBytes += stats.TotalBytes totalBytes += stats.TotalBytes
} }
} }
+2 -1
View File
@@ -1,8 +1,9 @@
package sfu package sfu
import ( import (
"github.com/livekit/livekit-server/pkg/sfu/buffer"
"github.com/livekit/protocol/logger" "github.com/livekit/protocol/logger"
"github.com/livekit/livekit-server/pkg/sfu/buffer"
) )
// //
+1 -1
View File
@@ -4,10 +4,10 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/livekit/protocol/logger"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/livekit/livekit-server/pkg/sfu/testutils" "github.com/livekit/livekit-server/pkg/sfu/testutils"
"github.com/livekit/protocol/logger"
) )
func newRTPMunger() *RTPMunger { func newRTPMunger() *RTPMunger {
+3 -2
View File
@@ -4,8 +4,9 @@ import (
"sync" "sync"
"time" "time"
"github.com/livekit/livekit-server/pkg/sfu/buffer"
"github.com/livekit/protocol/logger" "github.com/livekit/protocol/logger"
"github.com/livekit/livekit-server/pkg/sfu/buffer"
) )
const ( const (
@@ -127,7 +128,7 @@ func (n *sequencer) push(sn, offSn uint16, timeStamp uint32, layer uint8, head b
step = n.step - int(n.headSN-offSn) step = n.step - int(n.headSN-offSn)
if step < 0 { if step < 0 {
if step*-1 >= n.max { if step*-1 >= n.max {
n.logger.Infow("old packet received, can not be sequenced", "head", sn, "received", offSn) n.logger.Debugw("old packet received, can not be sequenced", "head", sn, "received", offSn)
return nil return nil
} }
step = n.max + step step = n.max + step
+1 -1
View File
@@ -5,10 +5,10 @@ import (
"testing" "testing"
"time" "time"
"github.com/livekit/protocol/logger"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/livekit/livekit-server/pkg/sfu/buffer" "github.com/livekit/livekit-server/pkg/sfu/buffer"
"github.com/livekit/protocol/logger"
) )
func Test_sequencer(t *testing.T) { func Test_sequencer(t *testing.T) {
+1 -1
View File
@@ -630,7 +630,7 @@ func (s *StreamAllocator) handleSignalSendProbe(event *Event) {
func (s *StreamAllocator) setState(state State) { func (s *StreamAllocator) setState(state State) {
if s.state != state { if s.state != state {
s.params.Logger.Infow("state change", "from", s.state, "to", state) s.params.Logger.Debugw("state change", "from", s.state, "to", state)
} }
s.state = state s.state = state
+1 -1
View File
@@ -2,9 +2,9 @@ package sfu
import ( import (
"github.com/elliotchance/orderedmap" "github.com/elliotchance/orderedmap"
"github.com/livekit/protocol/logger"
"github.com/livekit/livekit-server/pkg/sfu/buffer" "github.com/livekit/livekit-server/pkg/sfu/buffer"
"github.com/livekit/protocol/logger"
) )
// //
+1 -1
View File
@@ -4,11 +4,11 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/livekit/protocol/logger"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/livekit/livekit-server/pkg/sfu/buffer" "github.com/livekit/livekit-server/pkg/sfu/buffer"
"github.com/livekit/livekit-server/pkg/sfu/testutils" "github.com/livekit/livekit-server/pkg/sfu/testutils"
"github.com/livekit/protocol/logger"
) )
func compare(expected *VP8Munger, actual *VP8Munger) bool { func compare(expected *VP8Munger, actual *VP8Munger) bool {
+2 -1
View File
@@ -4,9 +4,10 @@ import (
"context" "context"
"github.com/gammazero/workerpool" "github.com/gammazero/workerpool"
"github.com/livekit/livekit-server/pkg/telemetry/prometheus"
"github.com/livekit/protocol/livekit" "github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/webhook" "github.com/livekit/protocol/webhook"
"github.com/livekit/livekit-server/pkg/telemetry/prometheus"
) )
type TelemetryServiceInternal interface { type TelemetryServiceInternal interface {
+2 -2
View File
@@ -204,7 +204,7 @@ func NewRTCClient(conn *websocket.Conn) (*RTCClient, error) {
c.publisher.OnOffer(c.onOffer) c.publisher.OnOffer(c.onOffer)
c.subscriber.PeerConnection().OnICEConnectionStateChange(func(connectionState webrtc.ICEConnectionState) { c.subscriber.PeerConnection().OnICEConnectionStateChange(func(connectionState webrtc.ICEConnectionState) {
logger.Infow("subscriber ICE state has changed", "state", connectionState.String(), logger.Debugw("subscriber ICE state has changed", "state", connectionState.String(),
"participant", c.localParticipant.Identity) "participant", c.localParticipant.Identity)
if connectionState == webrtc.ICEConnectionStateConnected { if connectionState == webrtc.ICEConnectionStateConnected {
// flush peers // flush peers
@@ -571,7 +571,7 @@ func (c *RTCClient) GetPublishedTrackIDs() []string {
c.lock.Lock() c.lock.Lock()
defer c.lock.Unlock() defer c.lock.Unlock()
var trackIDs []string var trackIDs []string
for key, _ := range c.localTracks { for key := range c.localTracks {
trackIDs = append(trackIDs, key) trackIDs = append(trackIDs, key)
} }
return trackIDs return trackIDs
+3 -3
View File
@@ -53,7 +53,7 @@ func (w *TrackWriter) Start() error {
return err return err
} }
logger.Infow("starting track writer", logger.Debugw("starting track writer",
"track", w.track.ID(), "track", w.track.ID(),
"mime", w.mime) "mime", w.mime)
switch w.mime { switch w.mime {
@@ -110,7 +110,7 @@ func (w *TrackWriter) writeOgg() {
} }
pageData, pageHeader, err := w.ogg.ParseNextPage() pageData, pageHeader, err := w.ogg.ParseNextPage()
if err == io.EOF { if err == io.EOF {
logger.Infow("all audio samples parsed and sent") logger.Debugw("all audio samples parsed and sent")
w.onWriteComplete() w.onWriteComplete()
return return
} }
@@ -144,7 +144,7 @@ func (w *TrackWriter) writeVP8() {
} }
frame, _, err := w.ivf.ParseNextFrame() frame, _, err := w.ivf.ParseNextFrame()
if err == io.EOF { if err == io.EOF {
logger.Infow("all video frames parsed and sent") logger.Debugw("all video frames parsed and sent")
w.onWriteComplete() w.onWriteComplete()
return return
} }
+2 -1
View File
@@ -4,9 +4,10 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/livekit/livekit-server/pkg/testutils"
"github.com/livekit/protocol/livekit" "github.com/livekit/protocol/livekit"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/livekit/livekit-server/pkg/testutils"
) )
func TestMultiNodeRoomList(t *testing.T) { func TestMultiNodeRoomList(t *testing.T) {
+3 -2
View File
@@ -5,12 +5,13 @@ import (
"testing" "testing"
"time" "time"
"github.com/livekit/livekit-server/pkg/testutils"
testclient "github.com/livekit/livekit-server/test/client"
"github.com/livekit/protocol/livekit" "github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger" "github.com/livekit/protocol/logger"
"github.com/livekit/protocol/utils" "github.com/livekit/protocol/utils"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/livekit/livekit-server/pkg/testutils"
testclient "github.com/livekit/livekit-server/test/client"
) )
// a scenario with lots of clients connecting, publishing, and leaving at random periods // a scenario with lots of clients connecting, publishing, and leaving at random periods
+1 -1
View File
@@ -8,7 +8,6 @@ import (
"testing" "testing"
"time" "time"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/protocol/auth" "github.com/livekit/protocol/auth"
"github.com/livekit/protocol/livekit" "github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger" "github.com/livekit/protocol/logger"
@@ -16,6 +15,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/thoas/go-funk" "github.com/thoas/go-funk"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/livekit-server/pkg/rtc" "github.com/livekit/livekit-server/pkg/rtc"
"github.com/livekit/livekit-server/pkg/testutils" "github.com/livekit/livekit-server/pkg/testutils"
testclient "github.com/livekit/livekit-server/test/client" testclient "github.com/livekit/livekit-server/test/client"