Documentation ¶
Overview ¶
HTTP interceptors for grpc-middleware for logging.
Index ¶
- func AddLogrusField(ctx context.Context, key, value string)
- func AddLogrusFields(ctx context.Context, fields logrus.Fields)
- func GetLogrusEntry(ctx context.Context, base *logrus.Entry) *logrus.Entry
- func GetLogrusFields(ctx context.Context) logrus.Fields
- func LogrusMethodInterceptor(base *logrus.Entry, t Timer, now Time) grpc.UnaryServerInterceptor
- func NewContext(ctx context.Context) context.Context
- func ReqID(ctx context.Context) string
- type ServiceLogger
- type Time
- type Timer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddLogrusField ¶
AddLogrusField adds a log field to the supplied context for later retrieval. The context must have been previously initialized with log metadata via `LogrusMethodInterceptor` or `NewContext`.
func AddLogrusFields ¶ added in v0.5.0
AddLogrusField adds log fields to the supplied context for later retrieval. The context must have been previously initialized with log metadata via `LogrusMethodInterceptor` or `NewContext`.
func GetLogrusEntry ¶
GetLogrusEntry returns stored logging metadata as a logrus Entry.
func GetLogrusFields ¶
GetLogrusFields returns stored logging metadata.
func LogrusMethodInterceptor ¶
LogrusMethodInterceptor returns a middleware that associates logrus.Fields with a handler's context.Context, accessible through func GetLogrusEntry(), and automatically logs method metadata.
func NewContext ¶ added in v0.5.0
NewContext returns a new context initialized with logging metadata.
Types ¶
type ServiceLogger ¶
ServiceLogger defines a function that returns a logrus.Entry from a context.Context
type Timer ¶
Timer acts as a stopwatch. The StartTimer function returns a function which, when called, returns the duration since StartTimer was called. There are no restrictions on the value returned when the function produced by StartTimer is called.
func SimpleTimer ¶
func SimpleTimer() Timer
SimpleTimer returns a basic timer that returns the difference between the StartTimer time and the 'stop' time, when the function returned by StartTimer is called.
If now is nil SimpleTimer will use the function time.Time to determine the current time.
func UpperBoundTimer ¶
UpperBoundTimer returns a Timer that rounds durations up to a multiple of the resolution. If resolution is zero a default value of time.Millisecond will be used. If resolution is negative a runtime panic will occur.