Documentation ¶
Index ¶
- Variables
- func Debug(serviceName string, methodName string, request proto.Message, ...)
- func Error(serviceName string, methodName string, request proto.Message, ...)
- func Info(serviceName string, methodName string, request proto.Message, ...)
- func Log(serviceName string, methodName string, request proto.Message, ...)
- func Warn(serviceName string, methodName string, request proto.Message, ...)
- type Call
- func (*Call) Descriptor() ([]byte, []int)
- func (m *Call) GetDuration() *google_protobuf.Duration
- func (m *Call) GetError() string
- func (m *Call) GetMethod() string
- func (m *Call) GetRequest() string
- func (m *Call) GetResponse() string
- func (m *Call) GetService() string
- func (*Call) ProtoMessage()
- func (m *Call) Reset()
- func (m *Call) String() string
- type Logger
Constants ¶
This section is empty.
Variables ¶
View Source
var (
// LoggingUnaryServerInterceptor is a grpc.UnaryServerInterceptor that logs every request and response.
LoggingUnaryServerInterceptor = newLoggingUnaryServerInterceptor()
)
Functions ¶
func Debug ¶
func Debug(serviceName string, methodName string, request proto.Message, response proto.Message, err error, duration time.Duration)
Debug logs an RPC call at the debug level.
func Error ¶
func Error(serviceName string, methodName string, request proto.Message, response proto.Message, err error, duration time.Duration)
Error logs an RPC call at the error level.
func Info ¶
func Info(serviceName string, methodName string, request proto.Message, response proto.Message, err error, duration time.Duration)
Info logs an RPC call at the info level.
Types ¶
type Call ¶
type Call struct { Service string `protobuf:"bytes,1,opt,name=service" json:"service,omitempty"` Method string `protobuf:"bytes,2,opt,name=method" json:"method,omitempty"` Request string `protobuf:"bytes,3,opt,name=request" json:"request,omitempty"` Response string `protobuf:"bytes,4,opt,name=response" json:"response,omitempty"` Error string `protobuf:"bytes,5,opt,name=error" json:"error,omitempty"` Duration *google_protobuf.Duration `protobuf:"bytes,6,opt,name=duration" json:"duration,omitempty"` }
func (*Call) GetDuration ¶
func (m *Call) GetDuration() *google_protobuf.Duration
type Logger ¶
type Logger interface {
Log(request proto.Message, response proto.Message, err error, duration time.Duration)
}
Logger is a logger intended to be used as such:
type apiServer struct { protorpclog.Logger ... }
func (a *apiServer) Foo(ctx Context.Context, request *FooRequest) (response *FooResponse, err error) { defer func(start time.Now) { a.Log(request, response, err, time.Since(start)) }(time.Now()) ... }
Click to show internal directories.
Click to hide internal directories.