mirror of
https://github.com/xaionaro-go/streamctl.git
synced 2025-09-27 03:45:52 +08:00
26 lines
603 B
Go
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)
|
|
}
|
|
}
|