log15ter

package module
v0.0.0-...-ce26492 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2018 License: Apache-2.0 Imports: 1 Imported by: 0

README

log15ter godoc reference Build Status

Package log15ter extends log15 with ternary handlers. A ternary handler allows for splitting the logic flow of the handler pipeline based on arbitrary decision points. This can be useful for conditionally adding more information to logs when it makes sense.

For example, the following will only call the stack trace handler if the log level is ERROR or above:

log15ter.LvlTernaryHandler(
	log15.LvlError,
	log15.CallerStackHandler("%+v", log15.StdoutHandler),
	log15.StdoutHandler)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LvlTernaryHandler

func LvlTernaryHandler(minLvl log15.Lvl, yes log15.Handler, no log15.Handler) log15.Handler

LvlTernaryHandler writes all logs above the log level provide to the `yes` handler. Otherwise it will write the logs to the `no` handler. For example you might want to add stack traces to logs only if the log level is error or above:

log15ter.LvlTernaryHandler(
    log15.LvlError,
    log15.CallerStackHandler("%+v", log15.StdoutHandler),
    log15.StdoutHandler)

func TernaryHandler

func TernaryHandler(fn func(r *log15.Record) bool, yes log15.Handler, no log15.Handler) log15.Handler

TernaryHandler writes all log records to the `yes` handler if the function is true. Otherwise it will write logs to the `no` handler.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL