Documentation
¶
Overview ¶
Package logmid is a net/http middleware that uses httpinfo and logger.Logger to log HTTP requests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddErrorInContext ¶
AddErrorInContext add an error field to the context. If there is already an error in the context, the original error will be wrap with the reason (err.Error()).
func AddFieldInContext ¶
AddFieldInContext add a log field to the context.
Types ¶
type LogAtLevelFunc ¶
LogAtLevelFunc defines the signature of the function that gives the level of the log function.
type OnRequestFunc ¶
OnRequestFunc defines the signature of the function called on each requests.
type Option ¶
type Option func(opts *Options)
Option defines a way to apply an option to the options.
func WithCallback ¶
func WithCallback(fcts ...OnRequestFunc) Option
WithCallback adds a function called each time a request is logged.
func WithDefaultFields ¶
func WithDefaultFields() Option
WithDefaultFields adds some fields to the request's log.
func WithLogLevelFunc ¶
func WithLogLevelFunc(fct LogAtLevelFunc) Option
WithLogLevelFunc adds a function to set logger's level based on the request.
func WithMessage ¶
WithMessage sets a custom message on each http request logs.