Files
streamctl/pkg/astiavlogger/callback.go
Dmitrii Okunev d504168a86
Some checks failed
rolling-release / build (push) Has been cancelled
rolling-release / rolling-release (push) Has been cancelled
Fix restreaming
2025-02-17 03:50:29 +00:00

26 lines
603 B
Go

package astiavlogger
import (
"strings"
"sync"
"github.com/asticode/go-astiav"
logger "github.com/facebookincubator/go-belt/tool/logger/types"
"github.com/xaionaro-go/avpipeline"
)
func Callback(l logger.Logger) astiav.LogCallback {
astiavLogger, setClassFunc := WrapLogger(l)
var astiavLoggerLocker sync.Mutex
return func(c astiav.Classer, level astiav.LogLevel, format, msg string) {
astiavLoggerLocker.Lock()
defer astiavLoggerLocker.Unlock()
setClassFunc(c)
astiavLogger.Logf(
avpipeline.LogLevelFromAstiav(level),
"%s", strings.TrimSpace(msg),
)
setClassFunc(nil)
}
}