mirror of
https://github.com/grafana/grafana.git
synced 2024-11-27 11:20:27 -06:00
05ea825c76
Fixing a couple bugs, adds some tests and hopefully decrease lock contention when logging. Switching from using sync.RWMutex to go-kit SwapLogger. Fixes bug when creating a new logger from an existing one that screwed up the keyvals and/or lost the logger name. Ref #44681
26 lines
550 B
Go
26 lines
550 B
Go
package log
|
|
|
|
import (
|
|
"testing"
|
|
|
|
gokitlog "github.com/go-kit/log"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestCompositeLogger(t *testing.T) {
|
|
loggedArgs := [][]interface{}{}
|
|
l := gokitlog.LoggerFunc(func(i ...interface{}) error {
|
|
loggedArgs = append(loggedArgs, i)
|
|
return nil
|
|
})
|
|
|
|
cl := newCompositeLogger(l, l, l)
|
|
require.NotNil(t, cl)
|
|
|
|
err := cl.Log("msg", "hello")
|
|
require.NoError(t, err)
|
|
require.Len(t, loggedArgs, 3)
|
|
require.Equal(t, "msg", loggedArgs[0][0].(string))
|
|
require.Equal(t, "hello", loggedArgs[0][1].(string))
|
|
}
|