Documentation ¶
Index ¶
- Constants
- func LogDeliverTxError(logger log.Logger, err error, blockHeight int64, handler string, msg sdk.Msg)
- func LogErrorWithOptionalContext(logger log.Logger, msg string, err error)
- func WrapErrorWithSourceModuleContext(err error, module string) error
- type ErrorWithLogContext
- type LogContextualizer
Constants ¶
const (
SourceModuleKey = "source_module"
)
Variables ¶
This section is empty.
Functions ¶
func LogDeliverTxError ¶
func LogDeliverTxError(logger log.Logger, err error, blockHeight int64, handler string, msg sdk.Msg)
LogDeliverTxError logs an error, appending the block height and ABCI callback to the error message.
func LogErrorWithOptionalContext ¶
LogErrorWithOptionalContext logs an error, optionally adding context to the logger iff the error implements the LogContextualizer interface. This method is appropriate for logging errors that may or may not be wrapped in an ErrorWithLogContext.
func WrapErrorWithSourceModuleContext ¶
WrapErrorWithPricesSourceModuleContext wraps an error with a LogContextualizer that contains a key-value pair for the specified source module. This can be used, for example, for wrapping validation failure errors that are logged within the process proposal handler (or from any other location that uses LogErrorWithOptionalContext) with metadata that helps to more easily identify the source of the error and correlate logs.
Types ¶
type ErrorWithLogContext ¶
type ErrorWithLogContext struct { LogContextualizer // contains filtered or unexported fields }
ErrorWithLogContext wraps an error with log context and implements the LogContextualizer interface. ErrorWithLogContext unwraps to the original error.
func NewErrorWithLogContext ¶
func NewErrorWithLogContext(err error) *ErrorWithLogContext
NewErrorWithLogContext returns a new ErrorWithLogContext wrapping the given error.
func (*ErrorWithLogContext) AddLoggingContext ¶
func (ewlc *ErrorWithLogContext) AddLoggingContext(logger log.Logger) log.Logger
AddLoggingContext returns a modified logger with the error's logging context added.
func (*ErrorWithLogContext) Error ¶
func (ewlc *ErrorWithLogContext) Error() string
Error returns the underlying error's Error() string.
func (*ErrorWithLogContext) Unwrap ¶
func (ewlc *ErrorWithLogContext) Unwrap() error
Unwrap returns the underlying error.
func (*ErrorWithLogContext) WithLogKeyValue ¶
func (ewlc *ErrorWithLogContext) WithLogKeyValue(key interface{}, value interface{}) *ErrorWithLogContext
WithLogKeyValue adds a key-value pair to the error's log context. The returned ErrorWithLogContext is the same error.
type LogContextualizer ¶
LogContextualizer describes an object that can add context - that is, descriptive key-value pairs, to a logger. This interface is implemented by ErrorWithLogContext, which wraps some errors that are returned from the protocol. This can be used, for example, to add context to log statements from the process proposal handler that helps with debugging erroneous unexpected and/or non-deterministic behaviors.