negronigomol

package module
v0.0.0-...-862959a Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2017 License: MIT Imports: 5 Imported by: 0

README

negroni-gomol

GoDoc Build Status Code Coverage

Negroni middleware to log with the Gomol log library.

Usage

Once gomol is initialized as you'd normally do (see the gomol documentation) you can create the logging middleware for Negroni in one of two ways.

The first way is to just use the current default gomol logger, like so:

import ng "github.com/aphistic/negroni-gomol"

...

n := negroni.New()
n.Use(ng.NewLogger())

If you have a different gomol Base logger you'd like to use instead, you can also use it in this way:

import ng "github.com/aphistic/negroni-gomol"

...

base := gomol.NewBase()

...

n := negroni.New()
n.Use(ng.NewLoggerForBase(base))

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	LogStart bool
	LogEnd   bool

	LogLevel gomol.LogLevel

	FieldMethod    string
	FieldPath      string
	FieldStatus    string
	FieldTimeMs    string
	FieldRequestID string
	// contains filtered or unexported fields
}

Logger is a Negroni middleware for logging requests with the gomol logging library

func NewLogger

func NewLogger() *Logger

NewLogger will create a new Logger using the current default gomol logger base

func NewLoggerForBase

func NewLoggerForBase(base *gomol.Base) *Logger

NewLoggerForBase will create a new Logger using the provided gomol logger base

func (*Logger) ServeHTTP

func (l *Logger) ServeHTTP(rw http.ResponseWriter, req *http.Request, next http.HandlerFunc)

Jump to

Keyboard shortcuts

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