fix: typo and avoid collides with log package name (#819)

pull/821/head
Cluas 4 years ago committed by GitHub
parent e1b9dd5244
commit 3636179347
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      middleware/logging/logging.go
  2. 4
      middleware/recovery/recovery.go
  3. 4
      transport/grpc/context.go
  4. 4
      transport/http/context.go

@ -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…
Cancel
Save