Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EscalateErrHandler ¶
EscalateErrHandler wraps another handler and passes all records through unchanged except if the logged context contains a non-nil error value in its context. In that case, the record's level is raised to LvlError unless it was already more serious (LvlCrit).
This allows you to log the result of all functions for debugging and still capture error conditions when in production with a single log line. As an example, the following the log record will be written out only if there was an error writing a value to redis:
logger := logext.EscalateErrHandler( log.LvlFilterHandler(log.LvlInfo, log.StdoutHandler)) reply, err := redisConn.Do("SET", "foo", "bar") logger.Debug("Wrote value to redis", "reply", reply, "err", err) if err != nil { return err }
func FatalHandler ¶
FatalHandler makes critical errors exit the program immediately, much like the log.Fatal* methods from the standard log package
Types ¶
type HotSwap ¶
type HotSwap struct {
// contains filtered or unexported fields
}
func HotSwapHandler ¶
HotSwapHandler wraps another handler that may swapped out dynamically at runtime in a thread-safe fashion. HotSwapHandler is the same functionality used to implement the SetHandler method for the default implementation of Logger.
type Speculative ¶
type Speculative struct {
// contains filtered or unexported fields
}
func SpeculativeHandler ¶
func SpeculativeHandler(size int, h log.Handler) *Speculative
SpeculativeHandler is a handler for speculative logging. It keeps a ring buffer of the given size full of the last events logged into it. When Flush is called, all buffered log records are written to the wrapped handler. This is extremely for continuosly capturing debug level output, but only flushing those log records if an exceptional condition is encountered.
func (*Speculative) Flush ¶
func (h *Speculative) Flush()