Update to new logging library, using sampling participant logger (#1219)
This commit is contained in:
@@ -10,7 +10,6 @@ require (
|
|||||||
github.com/florianl/go-tc v0.4.1
|
github.com/florianl/go-tc v0.4.1
|
||||||
github.com/gammazero/deque v0.1.0
|
github.com/gammazero/deque v0.1.0
|
||||||
github.com/gammazero/workerpool v1.1.2
|
github.com/gammazero/workerpool v1.1.2
|
||||||
github.com/go-logr/logr v1.2.3
|
|
||||||
github.com/go-redis/redis/v8 v8.11.5
|
github.com/go-redis/redis/v8 v8.11.5
|
||||||
github.com/google/wire v0.5.0
|
github.com/google/wire v0.5.0
|
||||||
github.com/gorilla/websocket v1.5.0
|
github.com/gorilla/websocket v1.5.0
|
||||||
@@ -18,7 +17,7 @@ require (
|
|||||||
github.com/hashicorp/golang-lru v0.6.0
|
github.com/hashicorp/golang-lru v0.6.0
|
||||||
github.com/livekit/mageutil v0.0.0-20221002073820-d9198083cfdc
|
github.com/livekit/mageutil v0.0.0-20221002073820-d9198083cfdc
|
||||||
github.com/livekit/mediatransportutil v0.0.0-20221007030528-7440725c362b
|
github.com/livekit/mediatransportutil v0.0.0-20221007030528-7440725c362b
|
||||||
github.com/livekit/protocol v1.2.5-0.20221208020623-5420927b7944
|
github.com/livekit/protocol v1.3.0
|
||||||
github.com/livekit/rtcscore-go v0.0.0-20220815072451-20ee10ae1995
|
github.com/livekit/rtcscore-go v0.0.0-20220815072451-20ee10ae1995
|
||||||
github.com/mackerelio/go-osstat v0.2.3
|
github.com/mackerelio/go-osstat v0.2.3
|
||||||
github.com/magefile/mage v1.14.0
|
github.com/magefile/mage v1.14.0
|
||||||
@@ -61,7 +60,7 @@ require (
|
|||||||
github.com/eapache/channels v1.1.0 // indirect
|
github.com/eapache/channels v1.1.0 // indirect
|
||||||
github.com/eapache/queue v1.1.0 // indirect
|
github.com/eapache/queue v1.1.0 // indirect
|
||||||
github.com/frostbyte73/go-throttle v0.0.0-20210621200530-8018c891361d // indirect
|
github.com/frostbyte73/go-throttle v0.0.0-20210621200530-8018c891361d // indirect
|
||||||
github.com/go-logr/zapr v1.2.3 // indirect
|
github.com/go-logr/logr v1.2.3 // indirect
|
||||||
github.com/golang/protobuf v1.5.2 // indirect
|
github.com/golang/protobuf v1.5.2 // indirect
|
||||||
github.com/google/go-cmp v0.5.8 // indirect
|
github.com/google/go-cmp v0.5.8 // indirect
|
||||||
github.com/google/subcommands v1.2.0 // indirect
|
github.com/google/subcommands v1.2.0 // indirect
|
||||||
|
|||||||
@@ -118,7 +118,6 @@ github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KE
|
|||||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||||
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
|
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
|
||||||
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||||
github.com/go-logr/zapr v1.2.3 h1:a9vnzlIBPQBBkeaR9IuMUfmVOrQlkoC4YfPoFkX3T7A=
|
|
||||||
github.com/go-logr/zapr v1.2.3/go.mod h1:eIauM6P8qSvTw5o2ez6UEAfGjQKrxQTl5EoK+Qa2oG4=
|
github.com/go-logr/zapr v1.2.3/go.mod h1:eIauM6P8qSvTw5o2ez6UEAfGjQKrxQTl5EoK+Qa2oG4=
|
||||||
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
||||||
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
||||||
@@ -246,8 +245,8 @@ github.com/livekit/mageutil v0.0.0-20221002073820-d9198083cfdc h1:e3GIA9AL6h4a38
|
|||||||
github.com/livekit/mageutil v0.0.0-20221002073820-d9198083cfdc/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
|
github.com/livekit/mageutil v0.0.0-20221002073820-d9198083cfdc/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
|
||||||
github.com/livekit/mediatransportutil v0.0.0-20221007030528-7440725c362b h1:RBNV8TckETSkIkKxcD12d8nZKVkB9GSY/sQlMoaruP4=
|
github.com/livekit/mediatransportutil v0.0.0-20221007030528-7440725c362b h1:RBNV8TckETSkIkKxcD12d8nZKVkB9GSY/sQlMoaruP4=
|
||||||
github.com/livekit/mediatransportutil v0.0.0-20221007030528-7440725c362b/go.mod h1:1Dlx20JPoIKGP45eo+yuj0HjeE25zmyeX/EWHiPCjFw=
|
github.com/livekit/mediatransportutil v0.0.0-20221007030528-7440725c362b/go.mod h1:1Dlx20JPoIKGP45eo+yuj0HjeE25zmyeX/EWHiPCjFw=
|
||||||
github.com/livekit/protocol v1.2.5-0.20221208020623-5420927b7944 h1:k7ULz4YXa7Bb+2hAzEp4/Wo5pEBazaTaFfnwBRLPLt0=
|
github.com/livekit/protocol v1.3.0 h1:9rzcKrLxZQIsL5Us2ZARmAkTw1dZJMF3WJoS6MCZUIw=
|
||||||
github.com/livekit/protocol v1.2.5-0.20221208020623-5420927b7944/go.mod h1:87MLIMbKaZs0SbDebMw1b7n/gD5utwEDq3zIRYcHJHA=
|
github.com/livekit/protocol v1.3.0/go.mod h1:87MLIMbKaZs0SbDebMw1b7n/gD5utwEDq3zIRYcHJHA=
|
||||||
github.com/livekit/rtcscore-go v0.0.0-20220815072451-20ee10ae1995 h1:vOaY2qvfLihDyeZtnGGN1Law9wRrw8BMGCr1TygTvMw=
|
github.com/livekit/rtcscore-go v0.0.0-20220815072451-20ee10ae1995 h1:vOaY2qvfLihDyeZtnGGN1Law9wRrw8BMGCr1TygTvMw=
|
||||||
github.com/livekit/rtcscore-go v0.0.0-20220815072451-20ee10ae1995/go.mod h1:116ych8UaEs9vfIE8n6iZCZ30iagUFTls0vRmC+Ix5U=
|
github.com/livekit/rtcscore-go v0.0.0-20220815072451-20ee10ae1995/go.mod h1:116ych8UaEs9vfIE8n6iZCZ30iagUFTls0vRmC+Ix5U=
|
||||||
github.com/mackerelio/go-osstat v0.2.3 h1:jAMXD5erlDE39kdX2CU7YwCGRcxIO33u/p8+Fhe5dJw=
|
github.com/mackerelio/go-osstat v0.2.3 h1:jAMXD5erlDE39kdX2CU7YwCGRcxIO33u/p8+Fhe5dJw=
|
||||||
|
|||||||
+18
-10
@@ -4,13 +4,14 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/go-logr/logr"
|
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
|
|
||||||
|
"github.com/livekit/protocol/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
// implements webrtc.LeveledLogger
|
// implements webrtc.LeveledLogger
|
||||||
type logAdapter struct {
|
type logAdapter struct {
|
||||||
logger logr.Logger
|
logger logger.Logger
|
||||||
level zapcore.Level
|
level zapcore.Level
|
||||||
ignoredPrefixes []string
|
ignoredPrefixes []string
|
||||||
}
|
}
|
||||||
@@ -27,14 +28,21 @@ func (l *logAdapter) Debug(msg string) {
|
|||||||
if l.level > zapcore.DebugLevel {
|
if l.level > zapcore.DebugLevel {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
l.logger.V(1).Info(msg)
|
if l.shouldIgnore(msg) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
l.logger.Debugw(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *logAdapter) Debugf(format string, args ...interface{}) {
|
func (l *logAdapter) Debugf(format string, args ...interface{}) {
|
||||||
if l.level > zapcore.DebugLevel {
|
if l.level > zapcore.DebugLevel {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
l.logger.V(1).Info(fmt.Sprintf(format, args...))
|
msg := fmt.Sprintf(format, args...)
|
||||||
|
if l.shouldIgnore(msg) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
l.logger.Debugw(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *logAdapter) Info(msg string) {
|
func (l *logAdapter) Info(msg string) {
|
||||||
@@ -44,7 +52,7 @@ func (l *logAdapter) Info(msg string) {
|
|||||||
if l.shouldIgnore(msg) {
|
if l.shouldIgnore(msg) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
l.logger.Info(msg)
|
l.logger.Infow(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *logAdapter) Infof(format string, args ...interface{}) {
|
func (l *logAdapter) Infof(format string, args ...interface{}) {
|
||||||
@@ -55,7 +63,7 @@ func (l *logAdapter) Infof(format string, args ...interface{}) {
|
|||||||
if l.shouldIgnore(msg) {
|
if l.shouldIgnore(msg) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
l.logger.Info(msg)
|
l.logger.Infow(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *logAdapter) Warn(msg string) {
|
func (l *logAdapter) Warn(msg string) {
|
||||||
@@ -65,7 +73,7 @@ func (l *logAdapter) Warn(msg string) {
|
|||||||
if l.shouldIgnore(msg) {
|
if l.shouldIgnore(msg) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
l.logger.V(-1).Info(msg)
|
l.logger.Warnw(msg, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *logAdapter) Warnf(format string, args ...interface{}) {
|
func (l *logAdapter) Warnf(format string, args ...interface{}) {
|
||||||
@@ -76,7 +84,7 @@ func (l *logAdapter) Warnf(format string, args ...interface{}) {
|
|||||||
if l.shouldIgnore(msg) {
|
if l.shouldIgnore(msg) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
l.logger.V(-1).Info(msg)
|
l.logger.Warnw(msg, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *logAdapter) Error(msg string) {
|
func (l *logAdapter) Error(msg string) {
|
||||||
@@ -86,7 +94,7 @@ func (l *logAdapter) Error(msg string) {
|
|||||||
if l.shouldIgnore(msg) {
|
if l.shouldIgnore(msg) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
l.logger.Error(nil, msg)
|
l.logger.Errorw(msg, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *logAdapter) Errorf(format string, args ...interface{}) {
|
func (l *logAdapter) Errorf(format string, args ...interface{}) {
|
||||||
@@ -97,7 +105,7 @@ func (l *logAdapter) Errorf(format string, args ...interface{}) {
|
|||||||
if l.shouldIgnore(msg) {
|
if l.shouldIgnore(msg) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
l.logger.Error(nil, msg)
|
l.logger.Errorw(msg, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *logAdapter) shouldIgnore(msg string) bool {
|
func (l *logAdapter) shouldIgnore(msg string) bool {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package serverlogger
|
package serverlogger
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/go-logr/logr"
|
|
||||||
"github.com/pion/logging"
|
"github.com/pion/logging"
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
|
|
||||||
@@ -35,13 +34,10 @@ var (
|
|||||||
|
|
||||||
// implements webrtc.LoggerFactory
|
// implements webrtc.LoggerFactory
|
||||||
type LoggerFactory struct {
|
type LoggerFactory struct {
|
||||||
logger logr.Logger
|
logger logger.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLoggerFactory(logger logr.Logger) *LoggerFactory {
|
func NewLoggerFactory(logger logger.Logger) *LoggerFactory {
|
||||||
if logger.GetSink() == nil {
|
|
||||||
logger = logr.Discard()
|
|
||||||
}
|
|
||||||
return &LoggerFactory{
|
return &LoggerFactory{
|
||||||
logger: logger,
|
logger: logger,
|
||||||
}
|
}
|
||||||
@@ -56,7 +52,7 @@ func (f *LoggerFactory) NewLogger(scope string) logging.LeveledLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Note: only pass in logr.Logger with default depth
|
// Note: only pass in logr.Logger with default depth
|
||||||
func SetLogger(l logr.Logger) {
|
func SetLogger(l logger.Logger) {
|
||||||
logger.SetLogger(l, "livekit")
|
logger.SetLogger(l, "livekit")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bep/debounce"
|
"github.com/bep/debounce"
|
||||||
|
|
||||||
"github.com/livekit/protocol/livekit"
|
"github.com/livekit/protocol/livekit"
|
||||||
"github.com/livekit/protocol/logger"
|
"github.com/livekit/protocol/logger"
|
||||||
|
|
||||||
@@ -35,6 +36,9 @@ type DynacastManager struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewDynacastManager(params DynacastManagerParams) *DynacastManager {
|
func NewDynacastManager(params DynacastManagerParams) *DynacastManager {
|
||||||
|
if params.Logger == nil {
|
||||||
|
params.Logger = logger.GetLogger()
|
||||||
|
}
|
||||||
d := &DynacastManager{
|
d := &DynacastManager{
|
||||||
params: params,
|
params: params,
|
||||||
dynacastQuality: make(map[string]*DynacastQuality),
|
dynacastQuality: make(map[string]*DynacastQuality),
|
||||||
@@ -84,22 +88,18 @@ func (d *DynacastManager) Close() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// THere are situations like track unmute or streaming from a sifferent node
|
// THere are situations like track unmute or streaming from a sifferent node
|
||||||
// where subscribed quality needs to sent to the provider immediately.
|
// where subscribed quality needs to sent to the provider immediately.
|
||||||
// This bypasses any debouncing and forces a subscribed quality update
|
// This bypasses any debouncing and forces a subscribed quality update
|
||||||
// with immediate effect.
|
// with immediate effect.
|
||||||
//
|
|
||||||
func (d *DynacastManager) ForceUpdate() {
|
func (d *DynacastManager) ForceUpdate() {
|
||||||
d.update(true)
|
d.update(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// It is possible for tracks to be in pending close state. When track
|
// It is possible for tracks to be in pending close state. When track
|
||||||
// is waiting to be closed, a node is not streaming a track. This can
|
// is waiting to be closed, a node is not streaming a track. This can
|
||||||
// be used to force an update announcing that subscribed quality is OFF,
|
// be used to force an update announcing that subscribed quality is OFF,
|
||||||
// i.e. indicating not pulling track any more.
|
// i.e. indicating not pulling track any more.
|
||||||
//
|
|
||||||
func (d *DynacastManager) ForceQuality(quality livekit.VideoQuality) {
|
func (d *DynacastManager) ForceQuality(quality livekit.VideoQuality) {
|
||||||
d.lock.Lock()
|
d.lock.Lock()
|
||||||
defer d.lock.Unlock()
|
defer d.lock.Unlock()
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import (
|
|||||||
|
|
||||||
"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/utils"
|
"github.com/livekit/protocol/utils"
|
||||||
|
|
||||||
"github.com/livekit/livekit-server/pkg/config"
|
"github.com/livekit/livekit-server/pkg/config"
|
||||||
@@ -467,8 +468,9 @@ func newParticipantForTestWithOpts(identity livekit.ParticipantIdentity, opts *p
|
|||||||
FmtpLine: c.FmtpLine,
|
FmtpLine: c.FmtpLine,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
sid := livekit.ParticipantID(utils.NewGuid(utils.ParticipantPrefix))
|
||||||
p, _ := NewParticipant(ParticipantParams{
|
p, _ := NewParticipant(ParticipantParams{
|
||||||
SID: livekit.ParticipantID(utils.NewGuid(utils.ParticipantPrefix)),
|
SID: sid,
|
||||||
Identity: identity,
|
Identity: identity,
|
||||||
Config: rtcConf,
|
Config: rtcConf,
|
||||||
Sink: &routingfakes.FakeMessageSink{},
|
Sink: &routingfakes.FakeMessageSink{},
|
||||||
@@ -478,6 +480,7 @@ func newParticipantForTestWithOpts(identity livekit.ParticipantIdentity, opts *p
|
|||||||
EnabledCodecs: enabledCodecs,
|
EnabledCodecs: enabledCodecs,
|
||||||
ClientConf: opts.clientConf,
|
ClientConf: opts.clientConf,
|
||||||
ClientInfo: ClientInfo{ClientInfo: opts.clientInfo},
|
ClientInfo: ClientInfo{ClientInfo: opts.clientInfo},
|
||||||
|
Logger: LoggerWithParticipant(logger.GetLogger(), identity, sid, false),
|
||||||
})
|
})
|
||||||
p.isPublisher.Store(opts.publisher)
|
p.isPublisher.Store(opts.publisher)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -85,7 +85,7 @@ func NewRoom(
|
|||||||
r := &Room{
|
r := &Room{
|
||||||
protoRoom: proto.Clone(room).(*livekit.Room),
|
protoRoom: proto.Clone(room).(*livekit.Room),
|
||||||
internal: internal,
|
internal: internal,
|
||||||
Logger: LoggerWithRoom(logger.GetDefaultLogger(), livekit.RoomName(room.Name), livekit.RoomID(room.Sid)),
|
Logger: LoggerWithRoom(logger.GetLogger(), livekit.RoomName(room.Name), livekit.RoomID(room.Sid)),
|
||||||
config: config,
|
config: config,
|
||||||
audioConfig: audioConfig,
|
audioConfig: audioConfig,
|
||||||
telemetry: telemetry,
|
telemetry: telemetry,
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bep/debounce"
|
"github.com/bep/debounce"
|
||||||
"github.com/go-logr/logr"
|
|
||||||
"github.com/pion/ice/v2"
|
"github.com/pion/ice/v2"
|
||||||
"github.com/pion/interceptor"
|
"github.com/pion/interceptor"
|
||||||
"github.com/pion/interceptor/pkg/cc"
|
"github.com/pion/interceptor/pkg/cc"
|
||||||
@@ -257,7 +256,7 @@ func newPeerConnection(params TransportParams, onBandwidthEstimator func(estimat
|
|||||||
se.SetDTLSRetransmissionInterval(dtlsRetransmissionInterval)
|
se.SetDTLSRetransmissionInterval(dtlsRetransmissionInterval)
|
||||||
se.SetICETimeouts(iceDisconnectedTimeout, iceFailedTimeout, iceKeepaliveInterval)
|
se.SetICETimeouts(iceDisconnectedTimeout, iceFailedTimeout, iceKeepaliveInterval)
|
||||||
|
|
||||||
lf := serverlogger.NewLoggerFactory(logr.Logger(params.Logger))
|
lf := serverlogger.NewLoggerFactory(params.Logger)
|
||||||
if lf != nil {
|
if lf != nil {
|
||||||
se.LoggerFactory = lf
|
se.LoggerFactory = lf
|
||||||
}
|
}
|
||||||
@@ -318,6 +317,9 @@ func newPeerConnection(params TransportParams, onBandwidthEstimator func(estimat
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewPCTransport(params TransportParams) (*PCTransport, error) {
|
func NewPCTransport(params TransportParams) (*PCTransport, error) {
|
||||||
|
if params.Logger == nil {
|
||||||
|
params.Logger = logger.GetLogger()
|
||||||
|
}
|
||||||
t := &PCTransport{
|
t := &PCTransport{
|
||||||
params: params,
|
params: params,
|
||||||
debouncedNegotiate: debounce.New(negotiationFrequency),
|
debouncedNegotiate: debounce.New(negotiationFrequency),
|
||||||
|
|||||||
@@ -76,6 +76,9 @@ type TransportManager struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewTransportManager(params TransportManagerParams) (*TransportManager, error) {
|
func NewTransportManager(params TransportManagerParams) (*TransportManager, error) {
|
||||||
|
if params.Logger == nil {
|
||||||
|
params.Logger = logger.GetLogger()
|
||||||
|
}
|
||||||
t := &TransportManager{
|
t := &TransportManager{
|
||||||
params: params,
|
params: params,
|
||||||
mediaLossProxy: NewMediaLossProxy(MediaLossProxyParams{Logger: params.Logger}),
|
mediaLossProxy: NewMediaLossProxy(MediaLossProxyParams{Logger: params.Logger}),
|
||||||
|
|||||||
@@ -6,14 +6,19 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/livekit/protocol/livekit"
|
"github.com/livekit/protocol/livekit"
|
||||||
|
"github.com/livekit/protocol/logger"
|
||||||
|
|
||||||
"github.com/livekit/livekit-server/pkg/rtc/types"
|
"github.com/livekit/livekit-server/pkg/rtc/types"
|
||||||
"github.com/livekit/livekit-server/pkg/rtc/types/typesfakes"
|
"github.com/livekit/livekit-server/pkg/rtc/types/typesfakes"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var defaultUptrackManagerParams = UpTrackManagerParams{
|
||||||
|
Logger: logger.GetLogger(),
|
||||||
|
}
|
||||||
|
|
||||||
func TestUpdateSubscriptionPermission(t *testing.T) {
|
func TestUpdateSubscriptionPermission(t *testing.T) {
|
||||||
t.Run("updates subscription permission", func(t *testing.T) {
|
t.Run("updates subscription permission", func(t *testing.T) {
|
||||||
um := NewUpTrackManager(UpTrackManagerParams{})
|
um := NewUpTrackManager(defaultUptrackManagerParams)
|
||||||
|
|
||||||
tra := &typesfakes.FakeMediaTrack{}
|
tra := &typesfakes.FakeMediaTrack{}
|
||||||
tra.IDReturns("audio")
|
tra.IDReturns("audio")
|
||||||
@@ -103,7 +108,7 @@ func TestUpdateSubscriptionPermission(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("updates subscription permission using both", func(t *testing.T) {
|
t.Run("updates subscription permission using both", func(t *testing.T) {
|
||||||
um := NewUpTrackManager(UpTrackManagerParams{})
|
um := NewUpTrackManager(defaultUptrackManagerParams)
|
||||||
|
|
||||||
tra := &typesfakes.FakeMediaTrack{}
|
tra := &typesfakes.FakeMediaTrack{}
|
||||||
tra.IDReturns("audio")
|
tra.IDReturns("audio")
|
||||||
@@ -176,7 +181,7 @@ func TestUpdateSubscriptionPermission(t *testing.T) {
|
|||||||
|
|
||||||
func TestSubscriptionPermission(t *testing.T) {
|
func TestSubscriptionPermission(t *testing.T) {
|
||||||
t.Run("checks subscription permission", func(t *testing.T) {
|
t.Run("checks subscription permission", func(t *testing.T) {
|
||||||
um := NewUpTrackManager(UpTrackManagerParams{})
|
um := NewUpTrackManager(defaultUptrackManagerParams)
|
||||||
|
|
||||||
tra := &typesfakes.FakeMediaTrack{}
|
tra := &typesfakes.FakeMediaTrack{}
|
||||||
tra.IDReturns("audio")
|
tra.IDReturns("audio")
|
||||||
|
|||||||
+15
-24
@@ -6,7 +6,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/go-logr/logr"
|
|
||||||
"github.com/pion/webrtc/v3"
|
"github.com/pion/webrtc/v3"
|
||||||
|
|
||||||
"github.com/livekit/protocol/livekit"
|
"github.com/livekit/protocol/livekit"
|
||||||
@@ -130,51 +129,43 @@ func Recover() {
|
|||||||
|
|
||||||
// logger helpers
|
// logger helpers
|
||||||
func LoggerWithParticipant(l logger.Logger, identity livekit.ParticipantIdentity, sid livekit.ParticipantID, isRemote bool) logger.Logger {
|
func LoggerWithParticipant(l logger.Logger, identity livekit.ParticipantIdentity, sid livekit.ParticipantID, isRemote bool) logger.Logger {
|
||||||
lr := logr.Logger(l)
|
values := make([]interface{}, 0, 4)
|
||||||
if identity != "" {
|
if identity != "" {
|
||||||
lr = lr.WithValues("participant", identity)
|
values = append(values, "participant", identity)
|
||||||
}
|
}
|
||||||
if sid != "" {
|
if sid != "" {
|
||||||
lr = lr.WithValues("pID", sid)
|
values = append(values, "pID", sid)
|
||||||
}
|
}
|
||||||
lr = lr.WithValues("remote", isRemote)
|
values = append(values, "remote", isRemote)
|
||||||
return logger.Logger(lr)
|
// enable sampling per participant
|
||||||
|
return l.WithItemSampler().WithValues(values...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoggerWithRoom(l logger.Logger, name livekit.RoomName, roomID livekit.RoomID) logger.Logger {
|
func LoggerWithRoom(l logger.Logger, name livekit.RoomName, roomID livekit.RoomID) logger.Logger {
|
||||||
lr := logr.Logger(l)
|
values := make([]interface{}, 0, 2)
|
||||||
if name != "" {
|
if name != "" {
|
||||||
lr = lr.WithValues("room", name)
|
values = append(values, "room", name)
|
||||||
}
|
}
|
||||||
if roomID != "" {
|
if roomID != "" {
|
||||||
lr = lr.WithValues("roomID", roomID)
|
values = append(values, "roomID", roomID)
|
||||||
}
|
}
|
||||||
return logger.Logger(lr)
|
return l.WithValues(values...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoggerWithTrack(l logger.Logger, trackID livekit.TrackID, isRelayed bool) logger.Logger {
|
func LoggerWithTrack(l logger.Logger, trackID livekit.TrackID, isRelayed bool) logger.Logger {
|
||||||
lr := logr.Logger(l)
|
|
||||||
if trackID != "" {
|
if trackID != "" {
|
||||||
lr = lr.WithValues("trackID", trackID)
|
return l.WithValues("trackID", trackID, "relayed", isRelayed)
|
||||||
lr = lr.WithValues("relayed", isRelayed)
|
|
||||||
}
|
}
|
||||||
return logger.Logger(lr)
|
return l
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoggerWithPCTarget(l logger.Logger, target livekit.SignalTarget) logger.Logger {
|
func LoggerWithPCTarget(l logger.Logger, target livekit.SignalTarget) logger.Logger {
|
||||||
lr := logr.Logger(l)
|
return l.WithValues("transport", target)
|
||||||
if lr.GetSink() == nil {
|
|
||||||
return l
|
|
||||||
}
|
|
||||||
|
|
||||||
lr = lr.WithValues("transport", target)
|
|
||||||
return logger.Logger(lr)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoggerWithCodecMime(l logger.Logger, mime string) logger.Logger {
|
func LoggerWithCodecMime(l logger.Logger, mime string) logger.Logger {
|
||||||
lr := logr.Logger(l)
|
|
||||||
if mime != "" {
|
if mime != "" {
|
||||||
lr = lr.WithValues("mime", mime)
|
return l.WithValues("mime", mime)
|
||||||
}
|
}
|
||||||
return logger.Logger(lr)
|
return l
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -461,7 +461,7 @@ func (r *RoomManager) rtcSessionWorker(room *rtc.Room, participant types.LocalPa
|
|||||||
defer rtc.Recover()
|
defer rtc.Recover()
|
||||||
|
|
||||||
pLogger := rtc.LoggerWithParticipant(
|
pLogger := rtc.LoggerWithParticipant(
|
||||||
rtc.LoggerWithRoom(logger.GetDefaultLogger(), room.Name(), room.ID()),
|
rtc.LoggerWithRoom(logger.GetLogger(), room.Name(), room.ID()),
|
||||||
participant.Identity(),
|
participant.Identity(),
|
||||||
participant.ID(),
|
participant.ID(),
|
||||||
false,
|
false,
|
||||||
@@ -529,7 +529,7 @@ func (r *RoomManager) handleRTCMessage(ctx context.Context, roomName livekit.Roo
|
|||||||
sid = participant.ID()
|
sid = participant.ID()
|
||||||
}
|
}
|
||||||
pLogger := rtc.LoggerWithParticipant(
|
pLogger := rtc.LoggerWithParticipant(
|
||||||
rtc.LoggerWithRoom(logger.GetDefaultLogger(), roomName, room.ID()),
|
rtc.LoggerWithRoom(logger.GetLogger(), roomName, room.ID()),
|
||||||
identity,
|
identity,
|
||||||
sid,
|
sid,
|
||||||
false,
|
false,
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ func (s *RTCService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pLogger := rtc.LoggerWithParticipant(
|
pLogger := rtc.LoggerWithParticipant(
|
||||||
rtc.LoggerWithRoom(logger.GetDefaultLogger(), roomName, livekit.RoomID(rm.Sid)),
|
rtc.LoggerWithRoom(logger.GetLogger(), roomName, livekit.RoomID(rm.Sid)),
|
||||||
pi.Identity,
|
pi.Identity,
|
||||||
pi.ID,
|
pi.ID,
|
||||||
false,
|
false,
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ func NewLivekitServer(conf *config.Config,
|
|||||||
middlewares = append(middlewares, NewAPIKeyAuthMiddleware(keyProvider))
|
middlewares = append(middlewares, NewAPIKeyAuthMiddleware(keyProvider))
|
||||||
}
|
}
|
||||||
|
|
||||||
twirpLoggingHook := TwirpLogger(logger.GetDefaultLogger())
|
twirpLoggingHook := TwirpLogger(logger.GetLogger())
|
||||||
roomServer := livekit.NewRoomServiceServer(roomService, twirpLoggingHook)
|
roomServer := livekit.NewRoomServiceServer(roomService, twirpLoggingHook)
|
||||||
egressServer := livekit.NewEgressServer(egressService, twirpLoggingHook)
|
egressServer := livekit.NewEgressServer(egressService, twirpLoggingHook)
|
||||||
ingressServer := livekit.NewIngressServer(ingressService, twirpLoggingHook)
|
ingressServer := livekit.NewIngressServer(ingressService, twirpLoggingHook)
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ type Buffer struct {
|
|||||||
|
|
||||||
// NewBuffer constructs a new Buffer
|
// NewBuffer constructs a new Buffer
|
||||||
func NewBuffer(ssrc uint32, vp, ap *sync.Pool) *Buffer {
|
func NewBuffer(ssrc uint32, vp, ap *sync.Pool) *Buffer {
|
||||||
l := logger.GetDefaultLogger() // will be reset with correct context via SetLogger
|
l := logger.GetLogger() // will be reset with correct context via SetLogger
|
||||||
b := &Buffer{
|
b := &Buffer{
|
||||||
mediaSSRC: ssrc,
|
mediaSSRC: ssrc,
|
||||||
videoPool: vp,
|
videoPool: vp,
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ func TestFpsVP8(t *testing.T) {
|
|||||||
frames := [][]*testFrameInfo{}
|
frames := [][]*testFrameInfo{}
|
||||||
vp8calcs := make([]*FrameRateCalculatorVP8, len(fps))
|
vp8calcs := make([]*FrameRateCalculatorVP8, len(fps))
|
||||||
for i := range vp8calcs {
|
for i := range vp8calcs {
|
||||||
vp8calcs[i] = NewFrameRateCalculatorVP8(90000, logger.Logger{})
|
vp8calcs[i] = NewFrameRateCalculatorVP8(90000, logger.GetLogger())
|
||||||
frames = append(frames, createFrames(c.startFrameNumber, c.startTs, 200, [][]float32{fps[i]}, false)[0])
|
frames = append(frames, createFrames(c.startFrameNumber, c.startTs, 200, [][]float32{fps[i]}, false)[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ func TestFpsVP8(t *testing.T) {
|
|||||||
frames := [][]*testFrameInfo{}
|
frames := [][]*testFrameInfo{}
|
||||||
vp8calcs := make([]*FrameRateCalculatorVP8, len(fps))
|
vp8calcs := make([]*FrameRateCalculatorVP8, len(fps))
|
||||||
for i := range vp8calcs {
|
for i := range vp8calcs {
|
||||||
vp8calcs[i] = NewFrameRateCalculatorVP8(90000, logger.Logger{})
|
vp8calcs[i] = NewFrameRateCalculatorVP8(90000, logger.GetLogger())
|
||||||
frames = append(frames, createFrames(100, 12345678, 300, [][]float32{fps[i]}, false)[0])
|
frames = append(frames, createFrames(100, 12345678, 300, [][]float32{fps[i]}, false)[0])
|
||||||
for j := 5; j < 130; j++ {
|
for j := 5; j < 130; j++ {
|
||||||
if j%2 == 0 {
|
if j%2 == 0 {
|
||||||
@@ -240,7 +240,7 @@ func TestFpsDD(t *testing.T) {
|
|||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
fps := testCase.fps
|
fps := testCase.fps
|
||||||
frames := createFrames(c.startFrameNumber, c.startTs, 500, fps, testCase.spatialDependency)
|
frames := createFrames(c.startFrameNumber, c.startTs, 500, fps, testCase.spatialDependency)
|
||||||
ddcalc := NewFrameRateCalculatorDD(90000, logger.Logger{})
|
ddcalc := NewFrameRateCalculatorDD(90000, logger.GetLogger())
|
||||||
ddcalc.SetMaxLayer(int32(len(fps)-1), int32(len(fps[0])-1))
|
ddcalc.SetMaxLayer(int32(len(fps)-1), int32(len(fps[0])-1))
|
||||||
ddcalcs := make([]FrameRateCalculator, len(fps))
|
ddcalcs := make([]FrameRateCalculator, len(fps))
|
||||||
for i := range fps {
|
for i := range fps {
|
||||||
@@ -273,7 +273,7 @@ func TestFpsDD(t *testing.T) {
|
|||||||
t.Run("packet lost and duplicate", func(t *testing.T) {
|
t.Run("packet lost and duplicate", func(t *testing.T) {
|
||||||
fps := [][]float32{{7.5, 15, 30}, {7.5, 15, 30}, {7.5, 15, 30}}
|
fps := [][]float32{{7.5, 15, 30}, {7.5, 15, 30}, {7.5, 15, 30}}
|
||||||
frames := createFrames(100, 12345678, 500, fps, true)
|
frames := createFrames(100, 12345678, 500, fps, true)
|
||||||
ddcalc := NewFrameRateCalculatorDD(90000, logger.Logger{})
|
ddcalc := NewFrameRateCalculatorDD(90000, logger.GetLogger())
|
||||||
ddcalc.SetMaxLayer(int32(len(fps)-1), int32(len(fps[0])-1))
|
ddcalc.SetMaxLayer(int32(len(fps)-1), int32(len(fps[0])-1))
|
||||||
ddcalcs := make([]FrameRateCalculator, len(fps))
|
ddcalcs := make([]FrameRateCalculator, len(fps))
|
||||||
for i := range fps {
|
for i := range fps {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ func disable(f *Forwarder) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newForwarder(codec webrtc.RTPCodecCapability, kind webrtc.RTPCodecType) *Forwarder {
|
func newForwarder(codec webrtc.RTPCodecCapability, kind webrtc.RTPCodecType) *Forwarder {
|
||||||
f := NewForwarder(kind, logger.GetDefaultLogger())
|
f := NewForwarder(kind, logger.GetLogger())
|
||||||
f.DetermineCodec(codec)
|
f.DetermineCodec(codec)
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -7,7 +7,6 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-logr/logr"
|
|
||||||
"github.com/pion/rtcp"
|
"github.com/pion/rtcp"
|
||||||
"github.com/pion/webrtc/v3"
|
"github.com/pion/webrtc/v3"
|
||||||
"go.uber.org/atomic"
|
"go.uber.org/atomic"
|
||||||
@@ -301,7 +300,7 @@ func (w *WebRTCReceiver) AddUpTrack(track *webrtc.TrackRemote, buff *buffer.Buff
|
|||||||
if w.Kind() == webrtc.RTPCodecTypeVideo {
|
if w.Kind() == webrtc.RTPCodecTypeVideo {
|
||||||
layer = buffer.RidToSpatialLayer(track.RID(), w.trackInfo)
|
layer = buffer.RidToSpatialLayer(track.RID(), w.trackInfo)
|
||||||
}
|
}
|
||||||
buff.SetLogger(logger.Logger(logr.Logger(w.logger).WithValues("layer", layer)))
|
buff.SetLogger(w.logger.WithValues("layer", layer))
|
||||||
buff.SetTWCC(w.twcc)
|
buff.SetTWCC(w.twcc)
|
||||||
buff.SetAudioLevelParams(audio.AudioLevelParams{
|
buff.SetAudioLevelParams(audio.AudioLevelParams{
|
||||||
ActiveLevel: w.audioConfig.ActiveLevel,
|
ActiveLevel: w.audioConfig.ActiveLevel,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func newRTPMunger() *RTPMunger {
|
func newRTPMunger() *RTPMunger {
|
||||||
return NewRTPMunger(logger.GetDefaultLogger())
|
return NewRTPMunger(logger.GetLogger())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetLastSnTs(t *testing.T) {
|
func TestSetLastSnTs(t *testing.T) {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Test_sequencer(t *testing.T) {
|
func Test_sequencer(t *testing.T) {
|
||||||
seq := newSequencer(500, 0, logger.GetDefaultLogger())
|
seq := newSequencer(500, 0, logger.GetLogger())
|
||||||
off := uint16(15)
|
off := uint16(15)
|
||||||
|
|
||||||
for i := uint16(1); i < 518; i++ {
|
for i := uint16(1); i < 518; i++ {
|
||||||
@@ -84,7 +84,7 @@ func Test_sequencer_getNACKSeqNo(t *testing.T) {
|
|||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
tt := tt
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
n := newSequencer(5, 10, logger.GetDefaultLogger())
|
n := newSequencer(5, 10, logger.GetLogger())
|
||||||
|
|
||||||
for _, i := range tt.fields.input {
|
for _, i := range tt.fields.input {
|
||||||
n.push(i, i+tt.fields.offset, 123, 3)
|
n.push(i, i+tt.fields.offset, 123, 3)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ func newStreamTracker(samplesRequired uint32, cyclesRequired uint32, cycleDurati
|
|||||||
CyclesRequired: cyclesRequired,
|
CyclesRequired: cyclesRequired,
|
||||||
CycleDuration: cycleDuration,
|
CycleDuration: cycleDuration,
|
||||||
BitrateReportInterval: 1 * time.Second,
|
BitrateReportInterval: 1 * time.Second,
|
||||||
Logger: logger.GetDefaultLogger(),
|
Logger: logger.GetLogger(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-logr/logr"
|
|
||||||
|
|
||||||
"github.com/livekit/livekit-server/pkg/sfu/buffer"
|
"github.com/livekit/livekit-server/pkg/sfu/buffer"
|
||||||
"github.com/livekit/protocol/livekit"
|
"github.com/livekit/protocol/livekit"
|
||||||
"github.com/livekit/protocol/logger"
|
"github.com/livekit/protocol/logger"
|
||||||
@@ -128,7 +126,7 @@ func (s *StreamTrackerManager) AddTracker(layer int32) *StreamTracker {
|
|||||||
|
|
||||||
params = ConfigVideo[layer]
|
params = ConfigVideo[layer]
|
||||||
}
|
}
|
||||||
params.Logger = logger.Logger(logr.Logger(s.logger).WithValues("layer", layer))
|
params.Logger = s.logger.WithValues("layer", layer)
|
||||||
tracker := NewStreamTracker(params)
|
tracker := NewStreamTracker(params)
|
||||||
s.logger.Debugw("StreamTrackerManager add track", "layer", layer)
|
s.logger.Debugw("StreamTrackerManager add track", "layer", layer)
|
||||||
tracker.OnStatusChanged(func(status StreamStatus) {
|
tracker.OnStatusChanged(func(status StreamStatus) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func compare(expected *VP8Munger, actual *VP8Munger) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newVP8Munger() *VP8Munger {
|
func newVP8Munger() *VP8Munger {
|
||||||
return NewVP8Munger(logger.GetDefaultLogger())
|
return NewVP8Munger(logger.GetLogger())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetLast(t *testing.T) {
|
func TestSetLast(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user