reqlog

package
v0.0.631 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0, MIT Imports: 7 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultAfter

func DefaultAfter(entry *logrusx.Logger, req *http.Request, res negroni.ResponseWriter, latency time.Duration, name string) *logrusx.Logger

DefaultAfter is the default func assigned to *Middleware.After

func DefaultBefore

func DefaultBefore(entry *logrusx.Logger, req *http.Request, remoteAddr string) *logrusx.Logger

DefaultBefore is the default func assigned to *Middleware.Before

func StartMeasureExternalCall added in v0.0.627

func StartMeasureExternalCall(ctx context.Context, cause, detail string, start time.Time)

StartMeasureExternalCall starts measuring the duration of an external call. The returned function has to be called to record the duration.

func WithDisableExternalLatencyMeasurement added in v0.0.627

func WithDisableExternalLatencyMeasurement(ctx context.Context) context.Context

WithDisableExternalLatencyMeasurement returns a context that does not measure external latencies. Use this when you want to disable external latency measurements for a specific request.

func WithEnableExternalLatencyMeasurement added in v0.0.627

func WithEnableExternalLatencyMeasurement(ctx context.Context) context.Context

WithEnableExternalLatencyMeasurement returns a context that measures external latencies.

Types

type AfterFunc

AfterFunc is the func type used to modify or replace the *logrusx.Logger after calling the next func in the middleware chain

type BeforeFunc

type BeforeFunc func(*logrusx.Logger, *http.Request, string) *logrusx.Logger

BeforeFunc is the func type used to modify or replace the *logrusx.Logger prior to calling the next func in the middleware chain

type Middleware

type Middleware struct {
	// Logger is the log.Logger instance used to log messages with the Logger middleware
	Logger *logrusx.Logger
	// Name is the name of the application as recorded in latency metrics
	Name   string
	Before func(*logrusx.Logger, *http.Request, string) *logrusx.Logger
	After  func(*logrusx.Logger, *http.Request, negroni.ResponseWriter, time.Duration, string) *logrusx.Logger

	sync.RWMutex
	// contains filtered or unexported fields
}

Middleware is a middleware handler that logs the request as it goes in and the response as it goes out.

func NewCustomMiddleware

func NewCustomMiddleware(level logrus.Level, formatter logrus.Formatter, name string) *Middleware

NewCustomMiddleware builds a *Middleware with the given level and formatter

func NewMiddleware

func NewMiddleware() *Middleware

NewMiddleware returns a new *Middleware, yay!

func NewMiddlewareFromLogger

func NewMiddlewareFromLogger(logger *logrusx.Logger, name string) *Middleware

NewMiddlewareFromLogger returns a new *Middleware which writes to a given logrus logger.

func (*Middleware) ExcludePaths

func (m *Middleware) ExcludePaths(paths ...string) *Middleware

ExcludePaths adds new URL paths to be ignored during logging. The URL u is parsed, hence the returned error

func (*Middleware) ServeHTTP

func (m *Middleware) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

func (*Middleware) SetLogStarting

func (m *Middleware) SetLogStarting(v bool)

SetLogStarting accepts a bool to control the logging of "started handling request" prior to passing to the next middleware

Jump to

Keyboard shortcuts

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