log

package
v0.0.0-...-745208b Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const LogId w.Key = "id"

Variables

This section is empty.

Functions

func StreamInterceptor

func StreamInterceptor(log grpclog.LoggerV2) grpc.StreamServerInterceptor

StreamInterceptor will use the log param to log the request duration. It also adds the request's id to the context

func UnaryInterceptor

func UnaryInterceptor(log grpclog.LoggerV2) grpc.UnaryServerInterceptor

UnaryInterceptor will use the log param to log the request duration. It also adds the request's id to the context

Types

type LogrusLogger

type LogrusLogger struct{ *logrus.Logger }

LogrusLogger implements the V method of the grpclog for the *logrus.Entry

Example

log := logrus.StandardLogger()
log.SetLevel(logrus.DebugLevel)
log.SetFormatter(
	&logrus.TextFormatter{
		ForceColors:      true,
		DisableColors:    false,
		TimestampFormat:  "2006-01-02 15:04:05",
		FullTimestamp:    true,
		QuoteEmptyFields: true,
		PadLevelText:     true,
	},
)
grpclog.SetLoggerV2(&log.LogrusLogger{l})

func (*LogrusLogger) V

func (s *LogrusLogger) V(l int) bool

V returns the result of current level == l

Jump to

Keyboard shortcuts

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