Documentation ¶
Index ¶
- func Ctx(ctx context.Context) *zerolog.Logger
- func MatchEchoLevel(level log.Lvl) (zerolog.Level, log.Lvl)
- func MatchZeroLevel(level zerolog.Level) (log.Lvl, zerolog.Level)
- func Middleware(config Config) echo.MiddlewareFunc
- type Config
- type Context
- type Enricher
- type InfoWriter
- type Logger
- func (l Logger) Debug(i ...interface{})
- func (l Logger) Debugf(format string, i ...interface{})
- func (l Logger) Debugj(j log.JSON)
- func (l Logger) Error(i ...interface{})
- func (l Logger) Errorf(format string, i ...interface{})
- func (l Logger) Errorj(j log.JSON)
- func (l Logger) Fatal(i ...interface{})
- func (l Logger) Fatalf(format string, i ...interface{})
- func (l Logger) Fatalj(j log.JSON)
- func (l Logger) Info(i ...interface{})
- func (l Logger) Infof(format string, i ...interface{})
- func (l Logger) Infoj(j log.JSON)
- func (l Logger) Level() log.Lvl
- func (l Logger) Output() io.Writer
- func (l Logger) Panic(i ...interface{})
- func (l Logger) Panicf(format string, i ...interface{})
- func (l Logger) Panicj(j log.JSON)
- func (l Logger) Prefix() string
- func (l Logger) Print(i ...interface{})
- func (l Logger) Printf(format string, i ...interface{})
- func (l Logger) Printj(j log.JSON)
- func (l Logger) SetHeader(h string)
- func (l *Logger) SetLevel(level log.Lvl)
- func (l *Logger) SetOutput(newOut io.Writer)
- func (l *Logger) SetPrefix(newPrefix string)
- func (l *Logger) Unwrap() zerolog.Logger
- func (l Logger) Warn(i ...interface{})
- func (l Logger) Warnf(format string, i ...interface{})
- func (l Logger) Warnj(j log.JSON)
- func (l Logger) WithContext(ctx context.Context) context.Context
- type Options
- type Setter
- func WithCaller() Setter
- func WithCallerWithSkipFrameCount(skipFrameCount int) Setter
- func WithField(name string, value interface{}) Setter
- func WithFields(fields map[string]interface{}) Setter
- func WithHook(hook zerolog.Hook) Setter
- func WithHookFunc(hook zerolog.HookFunc) Setter
- func WithLevel(level log.Lvl) Setter
- func WithPrefix(prefix string) Setter
- func WithTimestamp() Setter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Ctx ¶
Ctx returns a logger from the provided context. If no logger is found in the context, a new one is created.
func MatchEchoLevel ¶
MatchEchoLevel returns a zerolog level and echo level for a given echo level
func MatchZeroLevel ¶
MatchZeroLevel returns an echo level and zerolog level for a given zerolog level
func Middleware ¶
func Middleware(config Config) echo.MiddlewareFunc
Middleware returns a middleware which logs HTTP requests.
Types ¶
type Config ¶
type Config struct { // Logger is a custom instance of the logger to use. Logger *Logger // Skipper defines a function to skip middleware. Skipper middleware.Skipper // BeforeNext is a function that is executed before the next handler is called. BeforeNext middleware.BeforeFunc // Enricher is a function that can be used to enrich the logger with additional information. Enricher Enricher // RequestIDHeader is the header name to use for the request ID in a log record. RequestIDHeader string // RequestIDKey is the key name to use for the request ID in a log record. RequestIDKey string // NestKey is the key name to use for the nested logger in a log record. NestKey string // HandleError indicates whether to propagate errors up the middleware chain, so the global error handler can decide appropriate status code. HandleError bool }
Config is the configuration for the middleware.
type Context ¶
type Context struct { echo.Context // contains filtered or unexported fields }
Context is a wrapper around echo.Context that provides a logger.
func NewContext ¶
NewContext returns a new Context.
type Enricher ¶
Enricher is a function that can be used to enrich the logger with additional information.
type InfoWriter ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a wrapper around `zerolog.Logger` that provides an implementation of `echo.Logger` interface
type Setter ¶
type Setter func(opts *Options)
func WithCaller ¶
func WithCaller() Setter
func WithFields ¶
func WithHookFunc ¶
func WithPrefix ¶
func WithTimestamp ¶
func WithTimestamp() Setter