fix: use new sink api for logger package

This commit is contained in:
2021-03-29 12:06:50 +02:00
parent 1c740f8399
commit 576d5f8548
4 changed files with 20 additions and 5 deletions

View File

@ -40,18 +40,18 @@ func init() { // nolint: gochecknoinits
}
func Make(f Format, w io.Writer) slog.Logger {
var logger slog.Logger
var sink slog.Sink
switch f {
case FormatHuman:
logger = sloghuman.Make(w)
sink = sloghuman.Sink(w)
case FormatJSON:
logger = slogjson.Make(w)
sink = slogjson.Sink(w)
default:
panic(errors.Errorf("unknown logger format '%s'", f))
}
return logger
return slog.Make(sink)
}
func Debug(ctx context.Context, msg string, fields ...Field) {

13
logger/logger_test.go Normal file
View File

@ -0,0 +1,13 @@
package logger
import (
"context"
"os"
"testing"
)
func TestLogger(t *testing.T) {
log := Make(FormatHuman, os.Stdout)
log.Info(context.Background(), "test")
}