fix:fix suppress noisy LiveKit/pion logs in non-debug mode

This commit is contained in:
zarazaex69
2026-05-07 13:03:19 +03:00
parent 0956780c6f
commit 99ee4d8bbc
3 changed files with 16 additions and 1 deletions

View File

@@ -178,6 +178,7 @@ func configureLogging(debug bool) {
return
}
// Suppress noisy LiveKit/pion logs unless debug is enabled.
_ = os.Setenv("PION_LOG_DISABLE", "all")
lksdk.SetLogger(protoLogger.GetDiscardLogger())
}

View File

@@ -183,17 +183,24 @@ func TestRunWithArgsSuccessfulSessionReturn(t *testing.T) {
}
func TestConfigureLogging(t *testing.T) {
t.Setenv("PION_LOG_DISABLE", "")
logger.SetVerbose(false)
configureLogging(true)
if !logger.IsVerbose() {
t.Fatal("configureLogging(true) did not enable verbose logging")
}
if got := os.Getenv("PION_LOG_DISABLE"); got != "" {
t.Fatalf("configureLogging(true) PION_LOG_DISABLE = %q, want empty", got)
}
logger.SetVerbose(false)
configureLogging(false)
if logger.IsVerbose() {
t.Fatal("configureLogging(false) enabled verbose logging")
}
if got := os.Getenv("PION_LOG_DISABLE"); got != "all" {
t.Fatalf("configureLogging(false) PION_LOG_DISABLE = %q, want all", got)
}
}
func TestResolveDataDir(t *testing.T) {

View File

@@ -9,6 +9,7 @@ import (
"sync"
"sync/atomic"
protoLogger "github.com/livekit/protocol/logger"
lksdk "github.com/livekit/server-sdk-go/v2"
"github.com/pion/webrtc/v4"
)
@@ -92,7 +93,13 @@ func (p *Peer) Connect(ctx context.Context) error {
},
}
room, err := lksdk.ConnectToRoomWithToken(wsURL, token, roomCB, lksdk.WithAutoSubscribe(true))
room, err := lksdk.ConnectToRoomWithToken(
wsURL,
token,
roomCB,
lksdk.WithAutoSubscribe(true),
lksdk.WithLogger(protoLogger.GetDiscardLogger()),
)
if err != nil {
return fmt.Errorf("connect to room: %w", err)
}