fix: use new sink api for logger package
This commit is contained in:
@ -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
13
logger/logger_test.go
Normal 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")
|
||||
}
|
Reference in New Issue
Block a user