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 { for _, o := range opts {
o(&options) 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(handler middleware.Handler) middleware.Handler {
return func(ctx context.Context, req interface{}) (interface{}, error) { return func(ctx context.Context, req interface{}) (interface{}, error) {
var ( var (
@ -55,7 +55,7 @@ func Server(opts ...Option) middleware.Middleware {
} }
reply, err := handler(ctx, req) reply, err := handler(ctx, req)
if err != nil { if err != nil {
log.Errorw( logger.Errorw(
"kind", "server", "kind", "server",
"component", component, "component", component,
"path", path, "path", path,
@ -66,7 +66,7 @@ func Server(opts ...Option) middleware.Middleware {
) )
return nil, err return nil, err
} }
log.Infow( logger.Infow(
"kind", "server", "kind", "server",
"component", component, "component", component,
"path", path, "path", path,
@ -87,7 +87,7 @@ func Client(opts ...Option) middleware.Middleware {
for _, o := range opts { for _, o := range opts {
o(&options) 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(handler middleware.Handler) middleware.Handler {
return func(ctx context.Context, req interface{}) (interface{}, error) { return func(ctx context.Context, req interface{}) (interface{}, error) {
var ( var (
@ -109,7 +109,7 @@ func Client(opts ...Option) middleware.Middleware {
} }
reply, err := handler(ctx, req) reply, err := handler(ctx, req)
if err != nil { if err != nil {
log.Errorw( logger.Errorw(
"kind", "client", "kind", "client",
"component", component, "component", component,
"path", path, "path", path,
@ -120,7 +120,7 @@ func Client(opts ...Option) middleware.Middleware {
) )
return nil, err return nil, err
} }
log.Infow( logger.Infow(
"kind", "client", "kind", "client",
"component", component, "component", component,
"path", path, "path", path,

@ -45,7 +45,7 @@ func Recovery(opts ...Option) middleware.Middleware {
for _, o := range opts { for _, o := range opts {
o(&options) 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(handler middleware.Handler) middleware.Handler {
return func(ctx context.Context, req interface{}) (reply interface{}, err error) { return func(ctx context.Context, req interface{}) (reply interface{}, err error) {
defer func() { defer func() {
@ -53,7 +53,7 @@ func Recovery(opts ...Option) middleware.Middleware {
buf := make([]byte, 64<<10) buf := make([]byte, 64<<10)
n := runtime.Stack(buf, false) n := runtime.Stack(buf, false)
buf = buf[:n] 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) err = options.handler(ctx, req, rerr)
} }

@ -2,7 +2,7 @@ package grpc
import "context" import "context"
// ServerInfo is gRPC server infomation. // ServerInfo represent gRPC server information.
type ServerInfo struct { type ServerInfo struct {
// Server is the service implementation the user provides. This is read-only. // Server is the service implementation the user provides. This is read-only.
Server interface{} Server interface{}
@ -23,7 +23,7 @@ func FromServerContext(ctx context.Context) (info ServerInfo, ok bool) {
return return
} }
// ClientInfo is gRPC server infomation. // ClientInfo represent gRPC server information.
type ClientInfo struct { type ClientInfo struct {
// FullMethod is the full RPC method string, i.e., /package.service/method. // FullMethod is the full RPC method string, i.e., /package.service/method.
FullMethod string FullMethod string

@ -5,7 +5,7 @@ import (
"net/http" "net/http"
) )
// ServerInfo is HTTP server infomation. // ServerInfo represent HTTP server information.
type ServerInfo struct { type ServerInfo struct {
Request *http.Request Request *http.Request
Response http.ResponseWriter Response http.ResponseWriter
@ -24,7 +24,7 @@ func FromServerContext(ctx context.Context) (info ServerInfo, ok bool) {
return return
} }
// ClientInfo is HTTP client infomation. // ClientInfo represent HTTP client information.
type ClientInfo struct { type ClientInfo struct {
Request *http.Request Request *http.Request
} }

Loading…
Cancel
Save