log15.v2: gopkg.in/inconshreveable/log15.v2/ext Index | Files

package ext

import "gopkg.in/inconshreveable/log15.v2/ext"

Index

Package Files

handler.go id.go

func EscalateErrHandler Uses

func EscalateErrHandler(h log.Handler) log.Handler

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 Uses

func FatalHandler(h log.Handler) log.Handler

FatalHandler makes critical errors exit the program immediately, much like the log.Fatal* methods from the standard log package

func RandId Uses

func RandId(idlen int) string

RandId creates a random identifier of the requested length. Useful for assigning mostly-unique identifiers for logging and identification that are unlikely to collide because of short lifespan or low set cardinality

type HotSwap Uses

type HotSwap struct {
    // contains filtered or unexported fields
}

HotSwap is the Log15.Handler. Read `HotSwapHandler` for more information.

func HotSwapHandler Uses

func HotSwapHandler(h log.Handler) *HotSwap

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.

func (*HotSwap) Log Uses

func (h *HotSwap) Log(r *log.Record) error

Log implements log15.Handler interface.

func (*HotSwap) Swap Uses

func (h *HotSwap) Swap(newHandler log.Handler)

Swap atomically the logger handler.

type Speculative Uses

type Speculative struct {
    // contains filtered or unexported fields
}

Speculative is the Log15.Handler. Read `SpeculativeHandler` for more information.

func SpeculativeHandler Uses

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 Uses

func (h *Speculative) Flush()

Flush logs all records on the handler.

func (*Speculative) Log Uses

func (h *Speculative) Log(r *log.Record) error

Log implements log15.Handler interface

Package ext imports 8 packages (graph) and is imported by 16 packages. Updated 2018-08-20. Refresh now. Tools for package owners.