Documentation
¶
Index ¶
- Variables
- func AttachError(ctx context.Context, err error) error
- func AttachFields(ctx context.Context, fields ...logger.Field)
- func Logging(log *logger.Log, opts ...Option) func(http.Handler) http.Handler
- type Config
- type Option
- func WithEnableLogBody(b bool) Option
- func WithExternalEnableLogBody(b *atomic.Bool) Option
- func WithLogBodyContentType(contentTypes []string) Option
- func WithLogBodyLimit(limit int) Option
- func WithLogRecordRequestBody(f func(r *http.Request) bool) Option
- func WithLogRequestHeaders(headers []string) Option
- func WithLogResponseBody(f func(r *http.Request) bool) Option
- func WithLogResponseHeaders(headers []string) Option
- func WithSkipLogging(f func(r *http.Request) bool) Option
Constants ¶
This section is empty.
Variables ¶
var ErrClientAborted = errors.New("request aborted: client disconnected before response was sent")
Functions ¶
func AttachError ¶
AttachError attaches the error attribute on the request log.
func AttachFields ¶
AttachFields attaches the fields on the request log.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config logger/recover config
type Option ¶
type Option func(c *Config)
Option logger/recover option
func WithEnableLogBody ¶
WithEnableLogBody optional custom enable request/response body.
func WithExternalEnableLogBody ¶
WithExternalEnableLogBody optional custom enable request/response body control by external itself.
func WithLogBodyContentType ¶
WithLogBodyContentType optional custom record body content types.
func WithLogBodyLimit ¶
WithLogBodyLimit defines a list of body Content-Types that are safe to be logged. default: 4096, if <=0, mean not limit
func WithLogRecordRequestBody ¶
WithLogRecordRequestBody optional custom skip request body logging option.
func WithLogRequestHeaders ¶
WithLogRequestHeaders optional custom record request headers.
func WithLogResponseBody ¶
WithLogResponseBody optional custom skip response body logging option.
func WithLogResponseHeaders ¶
WithLogResponseHeaders optional custom record response headers.