tendermint: github.com/tendermint/tendermint/libs/log Index | Files

package log

import "github.com/tendermint/tendermint/libs/log"

Index

Package Files

filter.go logger.go nop_logger.go testing_logger.go tm_json_logger.go tm_logger.go tmfmt_logger.go tracing_logger.go

func NewSyncWriter Uses

func NewSyncWriter(w io.Writer) io.Writer

NewSyncWriter returns a new writer that is safe for concurrent use by multiple goroutines. Writes to the returned writer are passed on to w. If another write is already in progress, the calling goroutine blocks until the writer is available.

If w implements the following interface, so does the returned writer.

interface {
    Fd() uintptr
}

func NewTMFmtLogger Uses

func NewTMFmtLogger(w io.Writer) kitlog.Logger

NewTMFmtLogger returns a logger that encodes keyvals to the Writer in Tendermint custom format. Note complex types (structs, maps, slices) formatted as "%+v".

Each log event produces no more than one call to w.Write. The passed Writer must be safe for concurrent use by multiple goroutines if the returned Logger will be used concurrently.

type Logger Uses

type Logger interface {
    Debug(msg string, keyvals ...interface{})
    Info(msg string, keyvals ...interface{})
    Error(msg string, keyvals ...interface{})

    With(keyvals ...interface{}) Logger
}

Logger is what any Tendermint library should take.

func NewFilter Uses

func NewFilter(next Logger, options ...Option) Logger

NewFilter wraps next and implements filtering. See the commentary on the Option functions for a detailed description of how to configure levels. If no options are provided, all leveled log events created with Debug, Info or Error helper methods are squelched.

func NewNopLogger Uses

func NewNopLogger() Logger

NewNopLogger returns a logger that doesn't do anything.

func NewTMJSONLogger Uses

func NewTMJSONLogger(w io.Writer) Logger

NewTMJSONLogger returns a Logger that encodes keyvals to the Writer as a single JSON object. Each log event produces no more than one call to w.Write. The passed Writer must be safe for concurrent use by multiple goroutines if the returned Logger will be used concurrently.

func NewTMLogger Uses

func NewTMLogger(w io.Writer) Logger

NewTMTermLogger returns a logger that encodes msg and keyvals to the Writer using go-kit's log as an underlying logger and our custom formatter. Note that underlying logger could be swapped with something else.

func NewTMLoggerWithColorFn Uses

func NewTMLoggerWithColorFn(w io.Writer, colorFn func(keyvals ...interface{}) term.FgBgColor) Logger

NewTMLoggerWithColorFn allows you to provide your own color function. See NewTMLogger for documentation.

func NewTracingLogger Uses

func NewTracingLogger(next Logger) Logger

NewTracingLogger enables tracing by wrapping all errors (if they implement stackTracer interface) in tracedError.

All errors returned by https://github.com/pkg/errors implement stackTracer interface.

For debugging purposes only as it doubles the amount of allocations.

func TestingLogger Uses

func TestingLogger() Logger

TestingLogger returns a TMLogger which writes to STDOUT if testing being run with the verbose (-v) flag, NopLogger otherwise.

Note that the call to TestingLogger() must be made inside a test (not in the init func) because verbose flag only set at the time of testing.

func TestingLoggerWithColorFn Uses

func TestingLoggerWithColorFn(colorFn func(keyvals ...interface{}) term.FgBgColor) Logger

TestingLoggerWithColorFn allow you to provide your own color function. See TestingLogger for documentation.

func TestingLoggerWithOutput Uses

func TestingLoggerWithOutput(w io.Writer) Logger

TestingLoggerWOutput returns a TMLogger which writes to (w io.Writer) if testing being run with the verbose (-v) flag, NopLogger otherwise.

Note that the call to TestingLoggerWithOutput(w io.Writer) must be made inside a test (not in the init func) because verbose flag only set at the time of testing.

type Option Uses

type Option func(*filter)

Option sets a parameter for the filter.

func AllowAll Uses

func AllowAll() Option

AllowAll is an alias for AllowDebug.

func AllowDebug Uses

func AllowDebug() Option

AllowDebug allows error, info and debug level log events to pass.

func AllowDebugWith Uses

func AllowDebugWith(key interface{}, value interface{}) Option

AllowDebugWith allows error, info and debug level log events to pass for a specific key value pair.

func AllowError Uses

func AllowError() Option

AllowError allows only error level log events to pass.

func AllowErrorWith Uses

func AllowErrorWith(key interface{}, value interface{}) Option

AllowErrorWith allows only error level log events to pass for a specific key value pair.

func AllowInfo Uses

func AllowInfo() Option

AllowInfo allows error and info level log events to pass.

func AllowInfoWith Uses

func AllowInfoWith(key interface{}, value interface{}) Option

AllowInfoWith allows error and info level log events to pass for a specific key value pair.

func AllowLevel Uses

func AllowLevel(lvl string) (Option, error)

AllowLevel returns an option for the given level or error if no option exist for such level.

func AllowNone Uses

func AllowNone() Option

AllowNone allows no leveled log events to pass.

func AllowNoneWith Uses

func AllowNoneWith(key interface{}, value interface{}) Option

AllowNoneWith allows no leveled log events to pass for a specific key value pair.

Package log imports 12 packages (graph) and is imported by 162 packages. Updated 2019-01-23. Refresh now. Tools for package owners.