ctxlogger

package module
v1.5.12 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2021 License: BSD-2-Clause Imports: 4 Imported by: 2

README

ctxlogger

Build Status

Gizmo middleware that adds a logger to the context, including any path variables as logrus fields.

The folder examples include a example server that uses the middleware.

Documentation

Overview

Package ctxlogger provides a Gizmo middleware that automatically adds a given logger to the request context. It includes any path variable as fields in the logger.

Index

Constants

This section is empty.

Variables

View Source
var ContextKey = &struct{ key string }{key: "ctxlogger"}

ContextKey is the key used by the middleware to set the logger.

Functions

func ContextLogger

func ContextLogger(baseLogger *logrus.Logger) func(h http.Handler) http.Handler

ContextLogger takes the logger and returns the middleware that will always add the logger to the request context.

It also expands the logger with any path variable on the given request (using path variables as defined with Gizmo).

Last, but not least, it also tracks request ids using the header X-Request-Id.

Types

This section is empty.

Jump to

Keyboard shortcuts

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