log

package
v0.37.0-dev Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: Apache-2.0 Imports: 8 Imported by: 10,843

Documentation

Index

Constants

View Source
const (
	// LogFormatPlain defines a logging format used for human-readable text-based
	// logging that is not structured. Typically, this format is used for development
	// and testing purposes.
	LogFormatPlain string = "plain"

	// LogFormatText defines a logging format used for human-readable text-based
	// logging that is not structured. Typically, this format is used for development
	// and testing purposes.
	LogFormatText string = "text"

	// LogFormatJSON defines a logging format for structured JSON-based logging
	// that is typically used in production environments, which can be sent to
	// logging facilities that support complex log parsing and querying.
	LogFormatJSON string = "json"

	// Supported loging levels
	LogLevelDebug = "debug"
	LogLevelInfo  = "info"
	LogLevelWarn  = "warn"
	LogLevelError = "error"
)

Variables

This section is empty.

Functions

func OverrideWithNewLogger

func OverrideWithNewLogger(logger Logger, format, level string) error

OverrideWithNewLogger replaces an existing logger's internal with a new logger, and makes it possible to reconfigure an existing logger that has already been propagated to callers.

Types

type Logger

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

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

Logger defines a generic logging interface compatible with Tendermint.

func NewDefaultLogger added in v0.35.0

func NewDefaultLogger(format, level string) (Logger, error)

NewDefaultLogger returns a default logger that can be used within Tendermint and that fulfills the Logger interface. The underlying logging provider is a zerolog logger that supports typical log levels along with JSON and plain/text log formats.

Since zerolog supports typed structured logging and it is difficult to reflect that in a generic interface, all logging methods accept a series of key/value pair tuples, where the key must be a string.

func NewNopLogger

func NewNopLogger() Logger

func NewTestingLogger

func NewTestingLogger(t testing.TB) Logger

NewTestingLogger converts a testing.T into a logging interface to make test failures and verbose provide better feedback associated with test failures. This logging instance is safe for use from multiple threads, but in general you should create one of these loggers ONCE for each *testing.T instance that you interact with.

By default it collects only ERROR messages, or DEBUG messages in verbose mode, and relies on the underlying behavior of testing.T.Log()

Users should be careful to ensure that no calls to this logger are made in goroutines that are running after (which, by the rules of testing.TB will panic.)

func NewTestingLoggerWithLevel

func NewTestingLoggerWithLevel(t testing.TB, level string) Logger

NewTestingLoggerWithLevel creates a testing logger instance at a specific level that wraps the behavior of testing.T.Log().

Jump to

Keyboard shortcuts

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