loghttp

package
v0.0.0-...-cbc5a95 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2017 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LogRequests = NewRequestLogger(log.DefaultLogger).Middleware

LogRequests is a the default RequestLogger which will write to Stdout

Functions

func Error

func Error(w http.ResponseWriter, code int, message string, err error)

Error is a convenience function which will pass the givem message to log.Info, the given error to log.Debug, and then calls http.Error with the message and given code.

func Info

func Info(w http.ResponseWriter, code int, message string)

Info is a convenience function which will pass the given message to log.Info then call http.Error with the code and message.

Types

type RequestLogger

type RequestLogger struct {
	// contains filtered or unexported fields
}

RequestLogger creates a simple net/http middleware which captures metrics about a request/response and then logs it using the the specified Logger in aisola/log.

func NewRequestLogger

func NewRequestLogger(l *log.Logger) *RequestLogger

NewRequestLogger creates a new request logger from a log.Logger from aisola/log.

func (*RequestLogger) Middleware

func (rl *RequestLogger) Middleware(next http.Handler) http.Handler

Middleware returns the net/http middleware based on this RequestLogger.

Jump to

Keyboard shortcuts

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