weblogrus

package module
v0.0.0-...-b492fdd Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2017 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

weblogrus

GoDoc

A version of negroni-logrus designed to work with gocraft/web

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultAfter

func DefaultAfter(entry *logrus.Entry, res web.ResponseWriter, latency time.Duration, name string) *logrus.Entry

DefaultAfter is the default func assigned to *Middleware.After

func DefaultBefore

func DefaultBefore(entry *logrus.Entry, req *web.Request, remoteAddr string) *logrus.Entry

DefaultBefore is the default func assigned to *Middleware.Before

Types

type AfterFunc

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

type BeforeFunc

type BeforeFunc func(*logrus.Entry, *web.Request, string) *logrus.Entry

BeforeFunc is the func type used to modify or replace the *logrus.Entry 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 *logrus.Logger
	// Name is the name of the application as recorded in latency metrics
	Name   string
	Before func(*logrus.Entry, *web.Request, string) *logrus.Entry
	After  func(*logrus.Entry, web.ResponseWriter, time.Duration, string) *logrus.Entry
	// 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 *logrus.Logger, name string) *Middleware

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

func (*Middleware) ExcludeURL

func (m *Middleware) ExcludeURL(u string) error

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

func (*Middleware) ExcludedURLs

func (m *Middleware) ExcludedURLs() []string

ExcludedURLs returns the list of excluded URLs for this middleware

func (*Middleware) ServeHTTP

func (m *Middleware) ServeHTTP(rw web.ResponseWriter, r *web.Request, next web.NextMiddlewareFunc)

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