Documentation
¶
Index ¶
- Variables
- func AddCustomAttributes(c echo.Context, attrs ...slog.Attr)
- func New(logger *slog.Logger) echo.MiddlewareFunc
- func NewWithConfig(logger *slog.Logger, config Config) echo.MiddlewareFunc
- func NewWithFilters(logger *slog.Logger, filters ...Filter) echo.MiddlewareFunc
- type Config
- type Filter
- func Accept(filter Filter) Filter
- func AcceptHost(hosts ...string) Filter
- func AcceptHostContains(parts ...string) Filter
- func AcceptHostMatch(regs ...regexp.Regexp) Filter
- func AcceptHostPrefix(prefixs ...string) Filter
- func AcceptHostSuffix(prefixs ...string) Filter
- func AcceptMethod(methods ...string) Filter
- func AcceptPath(urls ...string) Filter
- func AcceptPathContains(parts ...string) Filter
- func AcceptPathMatch(regs ...regexp.Regexp) Filter
- func AcceptPathPrefix(prefixs ...string) Filter
- func AcceptPathSuffix(prefixs ...string) Filter
- func AcceptStatus(statuses ...int) Filter
- func AcceptStatusGreaterThan(status int) Filter
- func AcceptStatusGreaterThanOrEqual(status int) Filter
- func AcceptStatusLessThan(status int) Filter
- func AcceptStatusLessThanOrEqual(status int) Filter
- func Ignore(filter Filter) Filter
- func IgnoreHost(hosts ...string) Filter
- func IgnoreHostContains(parts ...string) Filter
- func IgnoreHostMatch(regs ...regexp.Regexp) Filter
- func IgnoreHostPrefix(prefixs ...string) Filter
- func IgnoreHostSuffix(suffixs ...string) Filter
- func IgnoreMethod(methods ...string) Filter
- func IgnorePath(urls ...string) Filter
- func IgnorePathContains(parts ...string) Filter
- func IgnorePathMatch(regs ...regexp.Regexp) Filter
- func IgnorePathPrefix(prefixs ...string) Filter
- func IgnorePathSuffix(suffixs ...string) Filter
- func IgnoreStatus(statuses ...int) Filter
- func IgnoreStatusGreaterThan(status int) Filter
- func IgnoreStatusGreaterThanOrEqual(status int) Filter
- func IgnoreStatusLessThan(status int) Filter
- func IgnoreStatusLessThanOrEqual(status int) Filter
Constants ¶
This section is empty.
Variables ¶
View Source
var ( TraceIDKey = "trace_id" SpanIDKey = "span_id" RequestIDKey = "id" RequestBodyMaxSize = 64 * 1024 // 64KB ResponseBodyMaxSize = 64 * 1024 // 64KB HiddenRequestHeaders = map[string]struct{}{ "authorization": {}, "cookie": {}, "set-cookie": {}, "x-auth-token": {}, "x-csrf-token": {}, "x-xsrf-token": {}, } HiddenResponseHeaders = map[string]struct{}{ "set-cookie": {}, } )
Functions ¶
func AddCustomAttributes ¶ added in v1.5.0
AddCustomAttributes adds custom attributes to the request context.
func New ¶
func New(logger *slog.Logger) echo.MiddlewareFunc
New returns a echo.MiddlewareFunc (middleware) that logs requests using slog.
Requests with errors are logged using slog.Error(). Requests without errors are logged using slog.Info().
func NewWithConfig ¶
func NewWithConfig(logger *slog.Logger, config Config) echo.MiddlewareFunc
NewWithConfig returns a echo.HandlerFunc (middleware) that logs requests using slog.
func NewWithFilters ¶ added in v1.3.0
func NewWithFilters(logger *slog.Logger, filters ...Filter) echo.MiddlewareFunc
NewWithFilters returns a echo.MiddlewareFunc (middleware) that logs requests using slog.
Requests with errors are logged using slog.Error(). Requests without errors are logged using slog.Info().
Types ¶
type Config ¶
type Config struct {
DefaultLevel slog.Level
ClientErrorLevel slog.Level
ServerErrorLevel slog.Level
WithUserAgent bool
WithRequestID bool
WithRequestBody bool
WithRequestHeader bool
WithResponseBody bool
WithResponseHeader bool
WithSpanID bool
WithTraceID bool
WithClientIP bool
WithCustomMessage func(c echo.Context, err error) string
Filters []Filter
}
func DefaultConfig ¶ added in v1.19.0
func DefaultConfig() Config
DefaultConfig returns the default configuration for the request logger.
type Filter ¶ added in v1.3.0
func AcceptHostContains ¶ added in v1.3.0
func AcceptHostMatch ¶ added in v1.3.0
func AcceptHostPrefix ¶ added in v1.3.0
func AcceptHostSuffix ¶ added in v1.3.0
func AcceptPathContains ¶ added in v1.3.0
func AcceptPathMatch ¶ added in v1.3.0
func AcceptPathPrefix ¶ added in v1.3.0
func AcceptPathSuffix ¶ added in v1.3.0
func AcceptStatusGreaterThan ¶ added in v1.3.0
func AcceptStatusGreaterThanOrEqual ¶ added in v1.3.0
func AcceptStatusLessThan ¶ added in v1.15.1
func AcceptStatusLessThanOrEqual ¶ added in v1.15.1
func IgnoreHost ¶ added in v1.3.0
func IgnoreHostContains ¶ added in v1.3.0
func IgnoreHostMatch ¶ added in v1.3.0
func IgnoreHostPrefix ¶ added in v1.3.0
func IgnoreHostSuffix ¶ added in v1.3.0
func IgnoreMethod ¶ added in v1.3.0
func IgnorePath ¶ added in v1.3.0
func IgnorePathContains ¶ added in v1.3.0
func IgnorePathMatch ¶ added in v1.3.0
func IgnorePathPrefix ¶ added in v1.3.0
func IgnorePathSuffix ¶ added in v1.3.0
func IgnoreStatus ¶ added in v1.3.0
func IgnoreStatusGreaterThan ¶ added in v1.15.1
func IgnoreStatusGreaterThanOrEqual ¶ added in v1.15.1
func IgnoreStatusLessThan ¶ added in v1.3.0
func IgnoreStatusLessThanOrEqual ¶ added in v1.3.0
Click to show internal directories.
Click to hide internal directories.