1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-11-06 08:59:18 +02:00

feat(log): add global logger appliance, as process level default logger (#1761)

* add global logger appliance, as process level default logger

* replace DefaultLogger as global logger
This commit is contained in:
realityone
2022-01-12 15:34:49 +08:00
committed by GitHub
parent d082075676
commit 0ed2e0f379
14 changed files with 210 additions and 16 deletions

View File

@@ -40,7 +40,7 @@ func WithLogger(logger log.Logger) Option {
// Recovery is a server middleware that recovers from any panics.
func Recovery(opts ...Option) middleware.Middleware {
op := options{
logger: log.DefaultLogger,
logger: log.GetLogger(),
handler: func(ctx context.Context, req, err interface{}) error {
return ErrUnknownRequest
},

View File

@@ -19,7 +19,7 @@ func TestOnce(t *testing.T) {
next := func(ctx context.Context, req interface{}) (interface{}, error) {
panic("panic reason")
}
_, e := Recovery(WithLogger(log.DefaultLogger))(next)(context.Background(), "panic")
_, e := Recovery(WithLogger(log.GetLogger()))(next)(context.Background(), "panic")
t.Logf("succ and reason is %v", e)
}