Documentation ¶
Overview ¶
Package clog15 provides utilities to embed and extract a log15.Logger to a context. This might be helpful to preserve logger context while being restricted by function signatures. For instance in http.HanderFunc, middleware or gRPC interceptors. It allows you to define logging context and attach the configured logger to a context passed down the executions chain.
Index ¶
- Constants
- func AddArgs(ctx context.Context, args ...interface{}) context.Context
- func Crit(ctx context.Context, msg string, args ...interface{})
- func Debug(ctx context.Context, msg string, args ...interface{})
- func Error(ctx context.Context, msg string, args ...interface{})
- func GetLogger(ctx context.Context) log.Logger
- func Info(ctx context.Context, msg string, args ...interface{})
- func NewLogger(ctx context.Context, args ...interface{}) context.Context
- func SetLogger(ctx context.Context, l log.Logger, args ...interface{}) context.Context
- func Warn(ctx context.Context, msg string, args ...interface{})
Constants ¶
const CtxLogger logKey = 1
CtxLogger is the context Value key which must be used.
Variables ¶
This section is empty.
Functions ¶
func AddArgs ¶
AddArgs to the logger in the returned context. If there is no logger set to context, a new root logger is returned with args.
func GetLogger ¶
GetLogger retrieves a logger from the context. If there is no logger set to context, a new root logger is returned.
func NewLogger ¶
NewLogger creates a new logger from the Root logger. It embeds the logger into the returned context. args are added to the logger's context.
Types ¶
This section is empty.