Use participant and room specific loggers (#252)
This commit is contained in:
@@ -265,8 +265,8 @@ func (t *MediaTrack) AddSubscriber(sub types.Participant) error {
|
||||
}
|
||||
t.params.Logger.Debugw("removing peerconnection track",
|
||||
"track", t.ID(),
|
||||
"pIDs", []string{t.params.ParticipantID, sub.ID()},
|
||||
"participant", sub.Identity(),
|
||||
"subscriber", sub.Identity(),
|
||||
"subscriberID", sub.ID(),
|
||||
"kind", t.Kind(),
|
||||
)
|
||||
if err := sub.SubscriberPC().RemoveTrack(sender); err != nil {
|
||||
@@ -279,7 +279,9 @@ func (t *MediaTrack) AddSubscriber(sub types.Participant) error {
|
||||
// been set to Inactive
|
||||
t.params.Logger.Debugw("could not remove remoteTrack from forwarder",
|
||||
"error", err,
|
||||
"participant", sub.Identity(), "pID", sub.ID())
|
||||
"subscriber", sub.Identity(),
|
||||
"subscriberID", sub.ID(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,8 +329,6 @@ func (t *MediaTrack) AddReceiver(receiver *webrtc.RTPReceiver, track *webrtc.Tra
|
||||
buff, rtcpReader := t.params.BufferFactory.GetBufferPair(uint32(track.SSRC()))
|
||||
if buff == nil || rtcpReader == nil {
|
||||
logger.Errorw("could not retrieve buffer pair", nil,
|
||||
"participant", t.params.ParticipantIdentity,
|
||||
"participantID", t.params.ParticipantID,
|
||||
"track", t.ID())
|
||||
return
|
||||
}
|
||||
|
||||
+26
-49
@@ -36,6 +36,7 @@ const (
|
||||
|
||||
type ParticipantParams struct {
|
||||
Identity string
|
||||
SID string
|
||||
Config *WebRTCConfig
|
||||
Sink routing.MessageSink
|
||||
AudioConfig config.AudioConfig
|
||||
@@ -50,7 +51,6 @@ type ParticipantParams struct {
|
||||
|
||||
type ParticipantImpl struct {
|
||||
params ParticipantParams
|
||||
id string
|
||||
publisher *PCTransport
|
||||
subscriber *PCTransport
|
||||
isClosed utils.AtomicFlag
|
||||
@@ -102,7 +102,6 @@ func NewParticipant(params ParticipantParams) (*ParticipantImpl, error) {
|
||||
|
||||
p := &ParticipantImpl{
|
||||
params: params,
|
||||
id: utils.NewGuid(utils.ParticipantPrefix),
|
||||
rtcpCh: make(chan []rtcp.Packet, 50),
|
||||
pliThrottle: newPLIThrottle(params.ThrottleConfig),
|
||||
subscribedTracks: make(map[string]types.SubscribedTrack),
|
||||
@@ -118,7 +117,7 @@ func NewParticipant(params ParticipantParams) (*ParticipantImpl, error) {
|
||||
return nil, err
|
||||
}
|
||||
p.publisher, err = NewPCTransport(TransportParams{
|
||||
ParticipantID: p.id,
|
||||
ParticipantID: p.params.SID,
|
||||
ParticipantIdentity: p.params.Identity,
|
||||
Target: livekit.SignalTarget_PUBLISHER,
|
||||
Config: params.Config,
|
||||
@@ -130,7 +129,7 @@ func NewParticipant(params ParticipantParams) (*ParticipantImpl, error) {
|
||||
return nil, err
|
||||
}
|
||||
p.subscriber, err = NewPCTransport(TransportParams{
|
||||
ParticipantID: p.id,
|
||||
ParticipantID: p.params.SID,
|
||||
ParticipantIdentity: p.params.Identity,
|
||||
Target: livekit.SignalTarget_SUBSCRIBER,
|
||||
Config: params.Config,
|
||||
@@ -188,7 +187,7 @@ func NewParticipant(params ParticipantParams) (*ParticipantImpl, error) {
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) ID() string {
|
||||
return p.id
|
||||
return p.params.SID
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) Identity() string {
|
||||
@@ -231,7 +230,7 @@ func (p *ParticipantImpl) RTCPChan() chan []rtcp.Packet {
|
||||
|
||||
func (p *ParticipantImpl) ToProto() *livekit.ParticipantInfo {
|
||||
info := &livekit.ParticipantInfo{
|
||||
Sid: p.id,
|
||||
Sid: p.params.SID,
|
||||
Identity: p.params.Identity,
|
||||
Metadata: p.metadata,
|
||||
State: p.State(),
|
||||
@@ -288,8 +287,8 @@ func (p *ParticipantImpl) OnClose(callback func(types.Participant)) {
|
||||
|
||||
// HandleOffer an offer from remote participant, used when clients make the initial connection
|
||||
func (p *ParticipantImpl) HandleOffer(sdp webrtc.SessionDescription) (answer webrtc.SessionDescription, err error) {
|
||||
p.params.Logger.Debugw("answering pub offer", "state", p.State().String(),
|
||||
"participant", p.Identity(), "pID", p.ID(),
|
||||
p.params.Logger.Debugw("answering pub offer",
|
||||
"state", p.State().String(),
|
||||
//"sdp", sdp.SDP,
|
||||
)
|
||||
|
||||
@@ -313,10 +312,8 @@ func (p *ParticipantImpl) HandleOffer(sdp webrtc.SessionDescription) (answer web
|
||||
return
|
||||
}
|
||||
|
||||
p.params.Logger.Debugw("sending answer to client",
|
||||
"participant", p.Identity(), "pID", p.ID(),
|
||||
//"answer sdp", answer.SDP,
|
||||
)
|
||||
p.params.Logger.Debugw("sending answer to client")
|
||||
|
||||
err = p.writeMessage(&livekit.SignalResponse{
|
||||
Message: &livekit.SignalResponse_Answer{
|
||||
Answer: ToProtoSessionDescription(answer),
|
||||
@@ -351,8 +348,7 @@ func (p *ParticipantImpl) AddTrack(req *livekit.AddTrackRequest) {
|
||||
}
|
||||
|
||||
if !p.CanPublish() {
|
||||
p.params.Logger.Warnw("no permission to publish track", nil,
|
||||
"participant", p.Identity(), "pID", p.ID())
|
||||
p.params.Logger.Warnw("no permission to publish track", nil)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -385,10 +381,7 @@ func (p *ParticipantImpl) HandleAnswer(sdp webrtc.SessionDescription) error {
|
||||
if sdp.Type != webrtc.SDPTypeAnswer {
|
||||
return ErrUnexpectedOffer
|
||||
}
|
||||
p.params.Logger.Debugw("setting subPC answer",
|
||||
"participant", p.Identity(), "pID", p.ID(),
|
||||
//"sdp", sdp.SDP,
|
||||
)
|
||||
p.params.Logger.Debugw("setting subPC answer")
|
||||
|
||||
if err := p.subscriber.SetRemoteDescription(sdp); err != nil {
|
||||
return errors.Wrap(err, "could not set remote description")
|
||||
@@ -485,8 +478,8 @@ func (p *ParticipantImpl) AddSubscriber(op types.Participant) (int, error) {
|
||||
}
|
||||
|
||||
p.params.Logger.Debugw("subscribing new participant to tracks",
|
||||
"participants", []string{p.Identity(), op.Identity()},
|
||||
"pIDs", []string{p.ID(), op.ID()},
|
||||
"subscriber", op.Identity(),
|
||||
"subscriberID", op.ID(),
|
||||
"numTracks", len(tracks))
|
||||
|
||||
n := 0
|
||||
@@ -646,8 +639,6 @@ func (p *ParticipantImpl) SetTrackMuted(trackId string, muted bool, fromAdmin bo
|
||||
|
||||
if currentMuted != track.IsMuted() && p.onTrackUpdated != nil {
|
||||
p.params.Logger.Debugw("mute status changed",
|
||||
"participant", p.Identity(),
|
||||
"pID", p.ID(),
|
||||
"track", trackId,
|
||||
"muted", track.IsMuted())
|
||||
p.onTrackUpdated(p, track)
|
||||
@@ -799,8 +790,9 @@ func (p *ParticipantImpl) GetSubscribedTracks() []types.SubscribedTrack {
|
||||
|
||||
// AddSubscribedTrack adds a track to the participant's subscribed list
|
||||
func (p *ParticipantImpl) AddSubscribedTrack(subTrack types.SubscribedTrack) {
|
||||
p.params.Logger.Debugw("added subscribedTrack", "publisher", subTrack.PublisherIdentity(),
|
||||
"participant", p.Identity(), "track", subTrack.ID())
|
||||
p.params.Logger.Debugw("added subscribedTrack",
|
||||
"publisher", subTrack.PublisherIdentity(),
|
||||
"track", subTrack.ID())
|
||||
p.lock.Lock()
|
||||
p.subscribedTracks[subTrack.ID()] = subTrack
|
||||
p.lock.Unlock()
|
||||
@@ -812,7 +804,7 @@ 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.params.Logger.Debugw("removed subscribedTrack", "publisher", subTrack.PublisherIdentity(),
|
||||
"participant", p.Identity(), "track", subTrack.ID(), "kind", subTrack.DownTrack().Kind())
|
||||
"track", subTrack.ID(), "kind", subTrack.DownTrack().Kind())
|
||||
|
||||
p.subscriber.RemoveTrack(subTrack)
|
||||
|
||||
@@ -836,8 +828,6 @@ func (p *ParticipantImpl) sendIceCandidate(c *webrtc.ICECandidate, target liveki
|
||||
|
||||
// write candidate
|
||||
p.params.Logger.Debugw("sending ice candidates",
|
||||
"participant", p.Identity(),
|
||||
"pID", p.ID(),
|
||||
"candidate", c.String())
|
||||
trickle := ToProtoTrickle(ci)
|
||||
trickle.Target = target
|
||||
@@ -854,7 +844,7 @@ func (p *ParticipantImpl) updateState(state livekit.ParticipantInfo_State) {
|
||||
return
|
||||
}
|
||||
p.state.Store(state)
|
||||
p.params.Logger.Debugw("updating participant state", "state", state.String(), "participant", p.Identity(), "pID", p.ID())
|
||||
p.params.Logger.Debugw("updating participant state", "state", state.String())
|
||||
p.lock.RLock()
|
||||
onStateChange := p.onStateChange
|
||||
p.lock.RUnlock()
|
||||
@@ -877,8 +867,6 @@ func (p *ParticipantImpl) writeMessage(msg *livekit.SignalResponse) error {
|
||||
err := sink.WriteMessage(msg)
|
||||
if err != nil {
|
||||
p.params.Logger.Warnw("could not send message to participant", err,
|
||||
"pID", p.ID(),
|
||||
"participant", p.Identity(),
|
||||
"message", fmt.Sprintf("%T", msg.Message))
|
||||
return err
|
||||
}
|
||||
@@ -888,15 +876,11 @@ func (p *ParticipantImpl) writeMessage(msg *livekit.SignalResponse) error {
|
||||
// when the server has an offer for participant
|
||||
func (p *ParticipantImpl) onOffer(offer webrtc.SessionDescription) {
|
||||
if p.State() == livekit.ParticipantInfo_DISCONNECTED {
|
||||
p.params.Logger.Debugw("skipping server offer", "participant", p.Identity(), "pID", p.ID())
|
||||
// skip when disconnected
|
||||
return
|
||||
}
|
||||
|
||||
p.params.Logger.Debugw("sending server offer to participant",
|
||||
"participant", p.Identity(), "pID", p.ID(),
|
||||
//"sdp", offer.SDP,
|
||||
)
|
||||
p.params.Logger.Debugw("sending server offer to participant")
|
||||
|
||||
err := p.writeMessage(&livekit.SignalResponse{
|
||||
Message: &livekit.SignalResponse_Offer{
|
||||
@@ -918,15 +902,12 @@ func (p *ParticipantImpl) onMediaTrack(track *webrtc.TrackRemote, rtpReceiver *w
|
||||
|
||||
p.params.Logger.Debugw("mediaTrack added",
|
||||
"kind", track.Kind().String(),
|
||||
"participant", p.Identity(),
|
||||
"pID", p.ID(),
|
||||
"track", track.ID(),
|
||||
"rid", track.RID(),
|
||||
"SSRC", track.SSRC())
|
||||
|
||||
if !p.CanPublish() {
|
||||
p.params.Logger.Warnw("no permission to publish mediaTrack", nil,
|
||||
"participant", p.Identity(), "pID", p.ID())
|
||||
p.params.Logger.Warnw("no permission to publish mediaTrack", nil)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -946,7 +927,7 @@ func (p *ParticipantImpl) onMediaTrack(track *webrtc.TrackRemote, rtpReceiver *w
|
||||
TrackInfo: ti,
|
||||
SignalCid: signalCid,
|
||||
SdpCid: track.ID(),
|
||||
ParticipantID: p.id,
|
||||
ParticipantID: p.params.SID,
|
||||
ParticipantIdentity: p.Identity(),
|
||||
RTCPChan: p.rtcpCh,
|
||||
BufferFactory: p.params.Config.BufferFactory,
|
||||
@@ -996,7 +977,7 @@ func (p *ParticipantImpl) onDataChannel(dc *webrtc.DataChannel) {
|
||||
p.handleDataMessage(livekit.DataPacket_LOSSY, msg.Data)
|
||||
})
|
||||
default:
|
||||
p.params.Logger.Warnw("unsupported datachannel added", nil, "participant", p.Identity(), "pID", p.ID(), "label", dc.Label())
|
||||
p.params.Logger.Warnw("unsupported datachannel added", nil, "label", dc.Label())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1060,7 +1041,7 @@ func (p *ParticipantImpl) handleDataMessage(kind livekit.DataPacket_Kind, data [
|
||||
switch payload := dp.Value.(type) {
|
||||
case *livekit.DataPacket_User:
|
||||
if p.onDataPacket != nil {
|
||||
payload.User.ParticipantSid = p.id
|
||||
payload.User.ParticipantSid = p.params.SID
|
||||
p.onDataPacket(p, &dp)
|
||||
}
|
||||
default:
|
||||
@@ -1092,8 +1073,6 @@ func (p *ParticipantImpl) handleTrackPublished(track types.PublishedTrack) {
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) handlePrimaryICEStateChange(state webrtc.ICEConnectionState) {
|
||||
// p.params.Logger.Debugw("ICE connection state changed", "state", state.String(),
|
||||
// "participant", p.identity, "pID", p.ID())
|
||||
if state == webrtc.ICEConnectionStateConnected {
|
||||
prometheus.ServiceOperationCounter.WithLabelValues("ice_connection", "success", "").Add(1)
|
||||
p.updateState(livekit.ParticipantInfo_ACTIVE)
|
||||
@@ -1160,8 +1139,7 @@ func (p *ParticipantImpl) downTracksRTCPWorker() {
|
||||
if err == io.EOF || err == io.ErrClosedPipe {
|
||||
return
|
||||
}
|
||||
logger.Errorw("could not send downtrack reports", err,
|
||||
"participant", p.Identity(), "pID", p.ID())
|
||||
logger.Errorw("could not send downtrack reports", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1200,8 +1178,7 @@ func (p *ParticipantImpl) rtcpSendWorker() {
|
||||
|
||||
if len(fwdPkts) > 0 {
|
||||
if err := p.publisher.pc.WriteRTCP(fwdPkts); err != nil {
|
||||
p.params.Logger.Errorw("could not write RTCP to participant", err,
|
||||
"participant", p.Identity(), "pID", p.ID())
|
||||
p.params.Logger.Errorw("could not write RTCP to participant", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1336,7 +1313,7 @@ func (p *ParticipantImpl) onStreamStateChange(update *sfu.StreamStateUpdate) err
|
||||
|
||||
func (p *ParticipantImpl) DebugInfo() map[string]interface{} {
|
||||
info := map[string]interface{}{
|
||||
"ID": p.id,
|
||||
"ID": p.params.SID,
|
||||
"State": p.State().String(),
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -60,7 +60,7 @@ type ParticipantOptions struct {
|
||||
func NewRoom(room *livekit.Room, config WebRTCConfig, audioConfig *config.AudioConfig, telemetry telemetry.TelemetryService) *Room {
|
||||
r := &Room{
|
||||
Room: proto.Clone(room).(*livekit.Room),
|
||||
Logger: logger.Logger(logger.GetLogger().WithValues("room", room.Name)),
|
||||
Logger: LoggerWithRoom(logger.Logger(logger.GetLogger()), room.Name),
|
||||
config: config,
|
||||
audioConfig: audioConfig,
|
||||
telemetry: telemetry,
|
||||
@@ -172,7 +172,10 @@ func (r *Room) Join(participant types.Participant, opts *ParticipantOptions, ice
|
||||
// it's important to set this before connection, we don't want to miss out on any publishedTracks
|
||||
participant.OnTrackPublished(r.onTrackPublished)
|
||||
participant.OnStateChange(func(p types.Participant, oldState livekit.ParticipantInfo_State) {
|
||||
r.Logger.Debugw("participant state changed", "state", p.State(), "participant", p.Identity(), "pID", p.ID(),
|
||||
r.Logger.Debugw("participant state changed",
|
||||
"state", p.State(),
|
||||
"participant", p.Identity(),
|
||||
"pID", p.ID(),
|
||||
"oldState", oldState)
|
||||
if r.onParticipantChanged != nil {
|
||||
r.onParticipantChanged(participant)
|
||||
|
||||
+10
-40
@@ -6,53 +6,32 @@ import (
|
||||
"github.com/livekit/protocol/logger"
|
||||
)
|
||||
|
||||
func HandleParticipantSignal(room types.Room, participant types.Participant, req *livekit.SignalRequest) error {
|
||||
func HandleParticipantSignal(room types.Room, participant types.Participant, req *livekit.SignalRequest, pLogger logger.Logger) error {
|
||||
switch msg := req.Message.(type) {
|
||||
case *livekit.SignalRequest_Offer:
|
||||
_, err := participant.HandleOffer(FromProtoSessionDescription(msg.Offer))
|
||||
if err != nil {
|
||||
logger.Errorw("could not handle offer", err,
|
||||
"room", room.Name(),
|
||||
"participant", participant.Identity(),
|
||||
"pID", participant.ID(),
|
||||
)
|
||||
pLogger.Errorw("could not handle offer", err)
|
||||
return err
|
||||
}
|
||||
case *livekit.SignalRequest_AddTrack:
|
||||
logger.Debugw("add track request",
|
||||
"room", room.Name(),
|
||||
"participant", participant.Identity(),
|
||||
"pID", participant.ID(),
|
||||
"track", msg.AddTrack.Cid)
|
||||
pLogger.Debugw("add track request", "track", msg.AddTrack.Cid)
|
||||
participant.AddTrack(msg.AddTrack)
|
||||
case *livekit.SignalRequest_Answer:
|
||||
sd := FromProtoSessionDescription(msg.Answer)
|
||||
if err := participant.HandleAnswer(sd); err != nil {
|
||||
logger.Errorw("could not handle answer", err,
|
||||
"room", room.Name(),
|
||||
"participant", participant.Identity(),
|
||||
"pID", participant.ID(),
|
||||
)
|
||||
pLogger.Errorw("could not handle answer", err)
|
||||
// connection cannot be successful if we can't answer
|
||||
return err
|
||||
}
|
||||
case *livekit.SignalRequest_Trickle:
|
||||
candidateInit, err := FromProtoTrickle(msg.Trickle)
|
||||
if err != nil {
|
||||
logger.Warnw("could not decode trickle", err,
|
||||
"room", room.Name(),
|
||||
"participant", participant.Identity(),
|
||||
"pID", participant.ID(),
|
||||
)
|
||||
pLogger.Warnw("could not decode trickle", err)
|
||||
return nil
|
||||
}
|
||||
// logger.Debugw("adding peer candidate", "participant", participant.Identity())
|
||||
if err := participant.AddICECandidate(candidateInit, msg.Trickle.Target); err != nil {
|
||||
logger.Warnw("could not handle trickle", err,
|
||||
"room", room.Name(),
|
||||
"participant", participant.Identity(),
|
||||
"pID", participant.ID(),
|
||||
)
|
||||
pLogger.Warnw("could not handle trickle", err)
|
||||
}
|
||||
case *livekit.SignalRequest_Mute:
|
||||
participant.SetTrackMuted(msg.Mute.Sid, msg.Mute.Muted, false)
|
||||
@@ -67,10 +46,7 @@ func HandleParticipantSignal(room types.Room, participant types.Participant, req
|
||||
err = ErrCannotSubscribe
|
||||
}
|
||||
if err != nil {
|
||||
logger.Warnw("could not update subscription", err,
|
||||
"room", room.Name(),
|
||||
"participant", participant.Identity(),
|
||||
"pID", participant.ID(),
|
||||
pLogger.Warnw("could not update subscription", err,
|
||||
"tracks", msg.Subscription.TrackSids,
|
||||
"subscribe", msg.Subscription.Subscribe)
|
||||
}
|
||||
@@ -78,26 +54,20 @@ func HandleParticipantSignal(room types.Room, participant types.Participant, req
|
||||
for _, sid := range msg.TrackSetting.TrackSids {
|
||||
subTrack := participant.GetSubscribedTrack(sid)
|
||||
if subTrack == nil {
|
||||
logger.Warnw("unable to find SubscribedTrack", nil,
|
||||
"room", room.Name(),
|
||||
"participant", participant.Identity(),
|
||||
"pID", participant.ID(),
|
||||
pLogger.Warnw("unable to find SubscribedTrack", nil,
|
||||
"track", sid)
|
||||
continue
|
||||
}
|
||||
|
||||
// find quality for published track
|
||||
logger.Debugw("updating track settings",
|
||||
"room", room.Name(),
|
||||
"participant", participant.Identity(),
|
||||
"pID", participant.ID(),
|
||||
pLogger.Debugw("updating track settings",
|
||||
"settings", msg.TrackSetting)
|
||||
subTrack.UpdateSubscriberSettings(msg.TrackSetting)
|
||||
}
|
||||
case *livekit.SignalRequest_UpdateLayers:
|
||||
track := participant.GetPublishedTrack(msg.UpdateLayers.TrackSid)
|
||||
if track == nil {
|
||||
logger.Warnw("could not find published track", nil,
|
||||
pLogger.Warnw("could not find published track", nil,
|
||||
"track", msg.UpdateLayers.TrackSid)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/bep/debounce"
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
livekit "github.com/livekit/protocol/livekit"
|
||||
"github.com/pion/interceptor"
|
||||
"github.com/pion/webrtc/v3"
|
||||
|
||||
@@ -100,8 +100,7 @@ func NewPCTransport(params TransportParams) (*PCTransport, error) {
|
||||
}
|
||||
if params.Target == livekit.SignalTarget_SUBSCRIBER {
|
||||
t.streamAllocator = sfu.NewStreamAllocator(sfu.StreamAllocatorParams{
|
||||
ParticipantID: params.ParticipantID,
|
||||
Logger: params.Logger,
|
||||
Logger: params.Logger,
|
||||
})
|
||||
t.streamAllocator.Start()
|
||||
}
|
||||
|
||||
+23
-1
@@ -6,8 +6,9 @@ import (
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
livekit "github.com/livekit/protocol/livekit"
|
||||
"github.com/pion/webrtc/v3"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/rtc/types"
|
||||
@@ -130,3 +131,24 @@ func Recover() {
|
||||
logger.GetLogger().Error(err, "recovered panic", "panic", r)
|
||||
}
|
||||
}
|
||||
|
||||
// logger helpers
|
||||
func LoggerWithParticipant(l logger.Logger, identity, sid string) logger.Logger {
|
||||
lr := logr.Logger(l)
|
||||
if identity != "" {
|
||||
lr = lr.WithValues("participant", identity)
|
||||
}
|
||||
if sid != "" {
|
||||
lr = lr.WithValues("pID", sid)
|
||||
}
|
||||
return logger.Logger(lr)
|
||||
}
|
||||
|
||||
func LoggerWithRoom(l logger.Logger, name string) logger.Logger {
|
||||
lr := logr.Logger(l)
|
||||
return logger.Logger(
|
||||
lr.WithValues(
|
||||
"room", name,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user