loghttp

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const RESPONSE_BODY_LOG_LIMIT = 1000

Maximum number of bytes of response body which will be logged.

Variables

This section is empty.

Functions

func LogMiddleware

func LogMiddleware(h http.Handler, infoLogger LogFunc, errorLogger LogFunc) http.Handler

LogMiddleware adds a logging middleware to an http.Handler. For each HTTP request the middleware will log via plog.CtxPlog(req.Context()).OpenDict("http-in"). When the handler is called it's with a "log" sub-context to that plog context.

The infoLogger and errorLogger arguments are deprecated but if non-nil those functions will be called with information about the request. infoLogger is called on 1xx, 2xx, 3xx requests, errorLogger is called otherwise. This is done in addition to the direct logging.

If h is nil then http.DefaultServeMux is used.

Types

type LogFunc

type LogFunc = func(map[string]interface{})

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳