MCPcopy
hub / github.com/rs/zerolog / FromRequest

Function FromRequest

hlog/hlog.go:19–21  ·  view source on GitHub ↗

FromRequest gets the logger in the request's context. This is a shortcut for log.Ctx(r.Context())

(r *http.Request)

Source from the content-addressed store, hash-verified

17// FromRequest gets the logger in the request's context.
18// This is a shortcut for log.Ctx(r.Context())
19func FromRequest(r *http.Request) *zerolog.Logger {
20 return log.Ctx(r.Context())
21}
22
23// NewHandler injects log into requests context.
24func NewHandler(log zerolog.Logger) func(http.Handler) http.Handler {

Callers 15

Example_handlerFunction · 0.92
TestNewHandlerFunction · 0.85
TestURLHandlerFunction · 0.85
TestMethodHandlerFunction · 0.85
TestRequestHandlerFunction · 0.85
TestRemoteAddrHandlerFunction · 0.85
TestRemoteIPHandlerFunction · 0.85
TestRemoteIPHandlerIPv6Function · 0.85
TestUserAgentHandlerFunction · 0.85
TestRefererHandlerFunction · 0.85
TestRequestIDHandlerFunction · 0.85

Calls 1

CtxFunction · 0.92

Tested by 15

Example_handlerFunction · 0.74
TestNewHandlerFunction · 0.68
TestURLHandlerFunction · 0.68
TestMethodHandlerFunction · 0.68
TestRequestHandlerFunction · 0.68
TestRemoteAddrHandlerFunction · 0.68
TestRemoteIPHandlerFunction · 0.68
TestRemoteIPHandlerIPv6Function · 0.68
TestUserAgentHandlerFunction · 0.68
TestRefererHandlerFunction · 0.68
TestRequestIDHandlerFunction · 0.68