Documentation ¶
Index ¶
Constants ¶
const ModuleKey = "module"
Defines commons keys for logging.
Variables ¶
var ContextKey struct{}
ContextKey is used to store the logger in the context.
Functions ¶
This section is empty.
Types ¶
type FilterFunc ¶
FilterFunc is a function that returns true if the log level is filtered for the given key When the filter returns true, the log entry is discarded.
func ParseLogLevel ¶
func ParseLogLevel(levelStr string) (FilterFunc, error)
ParseLogLevel parses complex log level A comma-separated list of module:level pairs with an optional *:level pair (* means all other modules).
Example: ParseLogLevel("consensus:debug,mempool:debug,*:error")
This function attemps to keep the same behavior as the CometBFT ParseLogLevel However the level `none` is replaced by `disabled`.
type Logger ¶
type Logger interface { // Info takes a message and a set of key/value pairs and logs with level INFO. // The key of the tuple must be a string. Info(msg string, keyVals ...any) // Error takes a message and a set of key/value pairs and logs with level ERR. // The key of the tuple must be a string. Error(msg string, keyVals ...any) // Debug takes a message and a set of key/value pairs and logs with level DEBUG. // The key of the tuple must be a string. Debug(msg string, keyVals ...any) // With returns a new wrapped logger with additional context provided by a set. With(keyVals ...any) Logger // Impl returns the underlying logger implementation. // It is used to access the full functionalities of the underlying logger. // Advanced users can type cast the returned value to the actual logger. Impl() any }
Logger is the Cosmos SDK logger interface. It maintains as much backward compatibility with the CometBFT logger as possible. All functionalities of the logger are available through the Impl() method.
func FilterKeys ¶
func FilterKeys(logger Logger, filter FilterFunc) Logger
FilterKeys returns a new logger that filters out all key/value pairs that do not match the filter. This functions assumes that the logger is a zerolog.Logger, which is the case for the logger returned by log.NewLogger(). NOTE: filtering has a performance impact on the logger.
func NewCustomLogger ¶
NewCustomLogger returns a new logger with the given zerolog logger.
func NewLogger ¶
NewLogger returns a new logger that writes to the given destination.
Typical usage from a main function is: logger := log.NewLogger(os.Stderr)
Stderr is the typical destination for logs, so that any output from your application can still be piped to other processes.
func NewLoggerWithKV ¶
NewLoggerWithKV is shorthand for NewLogger(dst).With(key, value).
type TestingT ¶
type TestingT zerolog.TestingLog
TestingT is the interface required for logging in tests. It is a subset of testing.T to avoid a direct dependency on the testing package.