protorpclog

package
v0.0.0-...-c5da4db Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2017 License: MIT Imports: 10 Imported by: 14

Documentation

Index

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.

func Log

func Log(serviceName string, methodName string, request proto.Message, response proto.Message, err error, duration time.Duration)

Log logs an RPC call at the info level if no error, or at the error level if error.

func Warn

func Warn(serviceName string, methodName string, request proto.Message, response proto.Message, err error, duration time.Duration)

Warn logs an RPC call at the warn 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) Descriptor

func (*Call) Descriptor() ([]byte, []int)

func (*Call) GetDuration

func (m *Call) GetDuration() *google_protobuf.Duration

func (*Call) GetError

func (m *Call) GetError() string

func (*Call) GetMethod

func (m *Call) GetMethod() string

func (*Call) GetRequest

func (m *Call) GetRequest() string

func (*Call) GetResponse

func (m *Call) GetResponse() string

func (*Call) GetService

func (m *Call) GetService() string

func (*Call) ProtoMessage

func (*Call) ProtoMessage()

func (*Call) Reset

func (m *Call) Reset()

func (*Call) String

func (m *Call) String() string

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())
  ...
}

func NewLogger

func NewLogger(serviceName string) Logger

NewLogger returns a new Logger.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL