mirror of
https://github.com/openlibrecommunity/olcrtc.git
synced 2026-05-26 07:08:11 +00:00
fix: suppress turnc ERROR noise from std log in non-debug mode
This commit is contained in:
@@ -2,11 +2,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
@@ -223,6 +225,27 @@ func parseFlagsFrom(args []string, errorHandling flag.ErrorHandling) (config, er
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
// noisyPrefixes lists log prefixes from third-party libs that spam via std log.
|
||||
var noisyPrefixes = [][]byte{ //nolint:gochecknoglobals // package-level filter list
|
||||
[]byte("turnc "),
|
||||
}
|
||||
|
||||
// filteredWriter wraps an io.Writer and drops lines whose prefix matches noisyPrefixes.
|
||||
type filteredWriter struct{ w io.Writer }
|
||||
|
||||
func (f filteredWriter) Write(p []byte) (int, error) {
|
||||
for _, prefix := range noisyPrefixes {
|
||||
if bytes.Contains(p, prefix) {
|
||||
return len(p), nil
|
||||
}
|
||||
}
|
||||
n, err := f.w.Write(p)
|
||||
if err != nil {
|
||||
return n, fmt.Errorf("log write: %w", err)
|
||||
}
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func configureLogging(debug bool) {
|
||||
if debug {
|
||||
logger.SetVerbose(true)
|
||||
@@ -231,6 +254,8 @@ func configureLogging(debug bool) {
|
||||
// Suppress noisy LiveKit/pion logs unless debug is enabled.
|
||||
_ = os.Setenv("PION_LOG_DISABLE", "all")
|
||||
lksdk.SetLogger(protoLogger.GetDiscardLogger())
|
||||
// turnc logs via std log directly — filter it out.
|
||||
log.SetOutput(filteredWriter{w: os.Stderr})
|
||||
}
|
||||
|
||||
func resolveDataDir(dataDir string) (string, error) {
|
||||
|
||||
Reference in New Issue
Block a user