mirror of
https://github.com/go-kratos/kratos.git
synced 2025-01-07 23:02:12 +02:00
fix: typo and avoid collides with log package name (#819)
This commit is contained in:
parent
e1b9dd5244
commit
3636179347
@ -33,7 +33,7 @@ func Server(opts ...Option) middleware.Middleware {
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
log := log.NewHelper("middleware/logging", options.logger)
|
||||
logger := log.NewHelper("middleware/logging", options.logger)
|
||||
return func(handler middleware.Handler) middleware.Handler {
|
||||
return func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
var (
|
||||
@ -55,7 +55,7 @@ func Server(opts ...Option) middleware.Middleware {
|
||||
}
|
||||
reply, err := handler(ctx, req)
|
||||
if err != nil {
|
||||
log.Errorw(
|
||||
logger.Errorw(
|
||||
"kind", "server",
|
||||
"component", component,
|
||||
"path", path,
|
||||
@ -66,7 +66,7 @@ func Server(opts ...Option) middleware.Middleware {
|
||||
)
|
||||
return nil, err
|
||||
}
|
||||
log.Infow(
|
||||
logger.Infow(
|
||||
"kind", "server",
|
||||
"component", component,
|
||||
"path", path,
|
||||
@ -87,7 +87,7 @@ func Client(opts ...Option) middleware.Middleware {
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
log := log.NewHelper("middleware/logging", options.logger)
|
||||
logger := log.NewHelper("middleware/logging", options.logger)
|
||||
return func(handler middleware.Handler) middleware.Handler {
|
||||
return func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
var (
|
||||
@ -109,7 +109,7 @@ func Client(opts ...Option) middleware.Middleware {
|
||||
}
|
||||
reply, err := handler(ctx, req)
|
||||
if err != nil {
|
||||
log.Errorw(
|
||||
logger.Errorw(
|
||||
"kind", "client",
|
||||
"component", component,
|
||||
"path", path,
|
||||
@ -120,7 +120,7 @@ func Client(opts ...Option) middleware.Middleware {
|
||||
)
|
||||
return nil, err
|
||||
}
|
||||
log.Infow(
|
||||
logger.Infow(
|
||||
"kind", "client",
|
||||
"component", component,
|
||||
"path", path,
|
||||
|
@ -45,7 +45,7 @@ func Recovery(opts ...Option) middleware.Middleware {
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
log := log.NewHelper("middleware/recovery", options.logger)
|
||||
logger := log.NewHelper("middleware/recovery", options.logger)
|
||||
return func(handler middleware.Handler) middleware.Handler {
|
||||
return func(ctx context.Context, req interface{}) (reply interface{}, err error) {
|
||||
defer func() {
|
||||
@ -53,7 +53,7 @@ func Recovery(opts ...Option) middleware.Middleware {
|
||||
buf := make([]byte, 64<<10)
|
||||
n := runtime.Stack(buf, false)
|
||||
buf = buf[:n]
|
||||
log.Errorf("%v: %+v\n%s\n", rerr, req, buf)
|
||||
logger.Errorf("%v: %+v\n%s\n", rerr, req, buf)
|
||||
|
||||
err = options.handler(ctx, req, rerr)
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package grpc
|
||||
|
||||
import "context"
|
||||
|
||||
// ServerInfo is gRPC server infomation.
|
||||
// ServerInfo represent gRPC server information.
|
||||
type ServerInfo struct {
|
||||
// Server is the service implementation the user provides. This is read-only.
|
||||
Server interface{}
|
||||
@ -23,7 +23,7 @@ func FromServerContext(ctx context.Context) (info ServerInfo, ok bool) {
|
||||
return
|
||||
}
|
||||
|
||||
// ClientInfo is gRPC server infomation.
|
||||
// ClientInfo represent gRPC server information.
|
||||
type ClientInfo struct {
|
||||
// FullMethod is the full RPC method string, i.e., /package.service/method.
|
||||
FullMethod string
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// ServerInfo is HTTP server infomation.
|
||||
// ServerInfo represent HTTP server information.
|
||||
type ServerInfo struct {
|
||||
Request *http.Request
|
||||
Response http.ResponseWriter
|
||||
@ -24,7 +24,7 @@ func FromServerContext(ctx context.Context) (info ServerInfo, ok bool) {
|
||||
return
|
||||
}
|
||||
|
||||
// ClientInfo is HTTP client infomation.
|
||||
// ClientInfo represent HTTP client information.
|
||||
type ClientInfo struct {
|
||||
Request *http.Request
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user