loggermiddleware

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: MIT Imports: 4 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MethodFieldName = "method"
View Source
var PathFieldName = "path"
View Source
var RequestIdFieldName = "request-id"

Functions

func AddCustomJsonLogField added in v0.4.0

func AddCustomJsonLogField(logFieldName string, valueExtractor func(r *http.Request) string)

AddCustomJsonLogField is a function to add custom fields to json logs.

DEPRECATED. This function is deprecated and calling it no longer has any effect!

Please use AddZerologLoggerToContextMiddleware and an options object to pass options.

func AddZerologLoggerToContext

func AddZerologLoggerToContext(next http.Handler) http.Handler

AddZerologLoggerToContext is a middleware to add a context aware logger to your context.

also supports logging request ids, just assign RequestIdFromContextRetriever before using this

func AddZerologLoggerToContextMiddleware added in v0.5.0

func AddZerologLoggerToContextMiddleware(options AddZerologLoggerToContextOptions) func(http.Handler) http.Handler

AddZerologLoggerToContextMiddleware constructs a middleware with the given options.

If you don't need to set custom options, you can just directly use AddZerologLoggerToContext as your middleware instead.

Types

type AddZerologLoggerToContextOptions added in v0.5.0

type AddZerologLoggerToContextOptions struct {
	CustomJsonLogFields []CustomJsonLogField
}

type CustomJsonLogField added in v0.5.0

type CustomJsonLogField struct {
	LogFieldName   string
	ValueExtractor func(r *http.Request) string
}

Jump to

Keyboard shortcuts

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