Documentation
¶
Index ¶
- func WrapHandlerContext(handlerCtx context.Context, realCtx *Context) context.Context
- type Context
- type DeferredKeyval
- type DeferredKeyvalInterface
- type LoggerContext
- func (lc *LoggerContext) Debug(msg interface{}, keyvals ...interface{})
- func (lc *LoggerContext) Debugf(format string, args ...interface{})
- func (lc *LoggerContext) Error(msg interface{}, keyvals ...interface{})
- func (lc *LoggerContext) Errorf(format string, args ...interface{})
- func (lc *LoggerContext) Fatal(msg interface{}, keyvals ...interface{})
- func (lc *LoggerContext) Fatalf(format string, args ...interface{})
- func (lc *LoggerContext) GetPrefix() string
- func (lc *LoggerContext) Info(msg interface{}, keyvals ...interface{})
- func (lc *LoggerContext) Infof(format string, args ...interface{})
- func (lc *LoggerContext) Log(level log.Level, msg interface{}, keyvals ...interface{})
- func (lc *LoggerContext) Logf(level log.Level, format string, args ...interface{})
- func (lc *LoggerContext) Print(msg interface{}, keyvals ...interface{})
- func (lc *LoggerContext) Printf(format string, args ...interface{})
- func (lc *LoggerContext) SetPrefix(prefix string)
- func (lc *LoggerContext) Step() *LoggerContext
- func (lc *LoggerContext) Warn(msg interface{}, keyvals ...interface{})
- func (lc *LoggerContext) Warnf(format string, args ...interface{})
- func (lc *LoggerContext) With(keyvals ...interface{}) *LoggerContext
- type StopwatchContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct {
context.Context
Log *LoggerContext
Stopwatch *StopwatchContext
// contains filtered or unexported fields
}
This should only contain fields that are realistically needed collectively whenever one is needed, while processing a DR command. This reduces the number of arguments that need to be passed around in the codebase. Doing so improves readability, at the cost of more "global" type values. However, given that nearly everything will need these values anyway, there isn't much downside in grouping them together.
func NewContext ¶
func UnwrapHandlerContext ¶
Unwrap the real context from the stdlib context type. If the context was not properly attached, return a new context with a message about the issue.
func (*Context) WithLogger ¶
func (c *Context) WithLogger(logger *LoggerContext) *Context
func (*Context) WithTimeout ¶
Returns a new context with the given timeout. If the timeout is 0, the new context will be cancellable, but will not have a timeout.
type DeferredKeyval ¶
type DeferredKeyval struct {
Key string
Value func() interface{}
}
func NewDeferredKeyval ¶
func NewDeferredKeyval(key string, value func() interface{}) *DeferredKeyval
func (*DeferredKeyval) Keyval ¶
func (dk *DeferredKeyval) Keyval() []interface{}
type DeferredKeyvalInterface ¶
type DeferredKeyvalInterface interface {
Keyval() []interface{}
}
func ErrorKeyvals ¶
func ErrorKeyvals(err *error) DeferredKeyvalInterface
Creates a common keyval for a future error. If the error is nil, the keyval will be be omitted entirely.
type LoggerContext ¶
func NewLoggerContext ¶
func NewLoggerContext(logger *log.Logger) *LoggerContext
func (*LoggerContext) Debug ¶
func (lc *LoggerContext) Debug(msg interface{}, keyvals ...interface{})
func (*LoggerContext) Debugf ¶
func (lc *LoggerContext) Debugf(format string, args ...interface{})
func (*LoggerContext) Error ¶
func (lc *LoggerContext) Error(msg interface{}, keyvals ...interface{})
func (*LoggerContext) Errorf ¶
func (lc *LoggerContext) Errorf(format string, args ...interface{})
func (*LoggerContext) Fatal ¶
func (lc *LoggerContext) Fatal(msg interface{}, keyvals ...interface{})
func (*LoggerContext) Fatalf ¶
func (lc *LoggerContext) Fatalf(format string, args ...interface{})
func (*LoggerContext) GetPrefix ¶
func (lc *LoggerContext) GetPrefix() string
func (*LoggerContext) Info ¶
func (lc *LoggerContext) Info(msg interface{}, keyvals ...interface{})
func (*LoggerContext) Infof ¶
func (lc *LoggerContext) Infof(format string, args ...interface{})
func (*LoggerContext) Log ¶
func (lc *LoggerContext) Log(level log.Level, msg interface{}, keyvals ...interface{})
func (*LoggerContext) Logf ¶
func (lc *LoggerContext) Logf(level log.Level, format string, args ...interface{})
func (*LoggerContext) Print ¶
func (lc *LoggerContext) Print(msg interface{}, keyvals ...interface{})
func (*LoggerContext) Printf ¶
func (lc *LoggerContext) Printf(format string, args ...interface{})
func (*LoggerContext) SetPrefix ¶
func (lc *LoggerContext) SetPrefix(prefix string)
func (*LoggerContext) Step ¶
func (lc *LoggerContext) Step() *LoggerContext
Creates a new logger instance with the same logger as the current logger, but with a new prefix that includes the step count. Successive calls to Step will increment the step count.
func (*LoggerContext) Warn ¶
func (lc *LoggerContext) Warn(msg interface{}, keyvals ...interface{})
func (*LoggerContext) Warnf ¶
func (lc *LoggerContext) Warnf(format string, args ...interface{})
func (*LoggerContext) With ¶
func (lc *LoggerContext) With(keyvals ...interface{}) *LoggerContext
Simple wrapper for the underlying logger `With` that returns the logger context.
type StopwatchContext ¶
func NewStopwatchContext ¶
func NewStopwatchContext() *StopwatchContext
func (*StopwatchContext) Elapsed ¶
func (sc *StopwatchContext) Elapsed() time.Duration
func (*StopwatchContext) Keyval ¶
func (sc *StopwatchContext) Keyval() *DeferredKeyval