Documentation
¶
Overview ¶
Package logger is a highly opinionated wrapper around the Zap logger
Index ¶
- func Fields(a ...any) (fields []zapcore.Field)
- func NewContextWithLogger(parentCtx context.Context, logger *Logger) context.Context
- type Field
- type Logger
- func (l *Logger) Clean()
- func (l *Logger) Debug(msg string)
- func (l *Logger) Error(msg string)
- func (l *Logger) Fatal(msg string)
- func (l *Logger) Info(msg string)
- func (logger *Logger) Middleware() func(http.Handler) http.Handler
- func (l *Logger) Warn(msg string)
- func (l *Logger) WithError(err error) *Logger
- func (l *Logger) WithField(key string, val interface{}) *Logger
- func (l *Logger) WithFields(f []zapcore.Field) *Logger
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger wraps zap.Logger.
func LoggerFromContext ¶
LoggerFromContext retrieves a logger from a context and panics if there isn't one.
func New ¶
New creates a new logger. Make sure to call defer logger.Clean() after calling this. Log messages are JSON Encoded and timestamps are RFC3339 encoded.
func (*Logger) Clean ¶
func (l *Logger) Clean()
Clean cleans up the log states. Make sure to call this after creating a new logger.
func (*Logger) Middleware ¶
Middleware is a middleware that adds the logger to the request context.