Documentation ¶
Overview ¶
Package chizap implements the zap logging middleware for chi. it's heavily influenced by gin middleware: https://github.com/thinkgos/zap
Index ¶
- func Chizap(logger *zap.Logger, timeFormat string, utc bool) func(http.Handler) http.Handler
- func Logger(logger *zap.Logger, opts ...Option) func(next http.Handler) http.Handler
- func Recovery(logger *zap.Logger, stack bool, opts ...Option) func(next http.Handler) http.Handler
- func RecoveryWithZap(logger *zap.Logger, stack bool) func(http.Handler) http.Handler
- type Config
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Chizap ¶
Chizap returns http middleware that logs requests using uber-go/zap.
It receives:
- A time package format string (e.g. time.RFC3339).
- A boolean stating whether to use UTC time zone or local.
func Logger ¶
Logger returns http middleware that logs requests using uber-go/zap.
Default option:
- A time package format string (e.g. time.RFC3339).(default time.RFC3339Nano)
- Use time zone.(e.g. utc time zone).(default local).
- Custom fields.(default nil)
func Recovery ¶
Recovery returns http middleware that recovers from any panics and logs requests using uber-go/zap. Errors are logged using zap.Error(). The stack parameter enables/disables output of the stack info. stack info can be very large.
func RecoveryWithZap ¶
RecoveryWithZap returns http middleware that recovers from any panics and logs requests using uber-go/zap. Errors are logged using zap.Error(). The stack parameter enables/disables output of the stack info. stack info can be very large.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is the configuration for logger/recover
type Option ¶
type Option func(c *Config)
Option is a functional configuration option
func WithCustomFields ¶
WithCustomFields appends optional custom fields to be logged.
func WithTimeFormat ¶
WithTimeFormat allows optionally passing a time package format string (e.g. time.RFC3339). (default time.RFC3339Nano).