mediamtx/internal/test/logger.go
Alessandro Ros 4c3ac34425
Some checks are pending
code_lint / golangci_lint (push) Waiting to run
code_lint / mod_tidy (push) Waiting to run
code_lint / api_docs (push) Waiting to run
code_test / test_64 (push) Waiting to run
code_test / test_32 (push) Waiting to run
code_test / test_highlevel (push) Waiting to run
fix memory leak in case of errors during initialization of a reader (#3831)
2024-10-05 00:49:44 +02:00

24 lines
595 B
Go

package test
import "github.com/bluenviron/mediamtx/internal/logger"
type nilLogger struct{}
func (nilLogger) Log(_ logger.Level, _ string, _ ...interface{}) {
}
// NilLogger is a logger to /dev/null
var NilLogger logger.Writer = &nilLogger{}
type testLogger struct {
cb func(level logger.Level, format string, args ...interface{})
}
func (l *testLogger) Log(level logger.Level, format string, args ...interface{}) {
l.cb(level, format, args...)
}
// Logger returns a test logger.
func Logger(cb func(logger.Level, string, ...interface{})) logger.Writer {
return &testLogger{cb: cb}
}