Documentation ¶
Overview ¶
Package ctxerror provides a context-aware error facility.
Inspired by log15-style (semi-)structured logging, it also provides a log15 bridge.
Index ¶
- func Crit(l log.Logger, e error, msg string, ctx ...interface{})
- func Debug(l log.Logger, e error, msg string, ctx ...interface{})
- func Error(l log.Logger, e error, msg string, ctx ...interface{})
- func Info(l log.Logger, e error, msg string, ctx ...interface{})
- func Log15(f Log15Func, e error)
- func Log15WithMsg(f Log15Func, e error, msg string, ctx ...interface{})
- func Trace(l log.Logger, e error, msg string, ctx ...interface{})
- func Warn(l log.Logger, e error, msg string, ctx ...interface{})
- type CtxError
- type Log15Func
- type Log15Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Log15 ¶
Log15 logs an error with a log15-style logging function. It handles both regular errors and Log15Logger-compliant errors.
func Log15WithMsg ¶
Log15WithMsg logs an error with a message prefix using a log15-style logging function. It is a shortcut for a common pattern of prepending a context prefix.
Types ¶
type CtxError ¶
type CtxError interface { // Error returns a fully formatted message, with context info. Error() string // Message returns the bare error message, without context info. Message() string // Contexts returns message contexts. // Caller shall not modify the returned map. Contexts() map[string]interface{} // WithCause chains an error after the receiver. // It returns the merged/chained instance, // where the message is "<receiver.Message>: <c.Message>", // and with contexts merged (ones in c takes precedence). WithCause(c error) CtxError }
CtxError is a context-aware error container.
type Log15Func ¶
type Log15Func func(msg string, ctx ...interface{})
Log15Func is a log15-compatible logging function.
type Log15Logger ¶
type Log15Logger interface {
Log15(f Log15Func)
}
Log15Logger logs something with a log15-style logging function.
Click to show internal directories.
Click to hide internal directories.