utils

package
v3.2.2-near-experimental Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LAVA_LOG_TRACE = iota
	LAVA_LOG_DEBUG
	LAVA_LOG_INFO
	LAVA_LOG_WARN
	LAVA_LOG_ERROR
	LAVA_LOG_FATAL
	LAVA_LOG_PANIC
	NoColor = true
)
View Source
const (
	EventPrefix = "lava_"
)
View Source
const MONTHS_IN_YEAR = 12
View Source
const TIMEOUT = 10

Variables

View Source
var (
	JsonFormat = false
	// if set to production, this will replace some errors to warning that can be caused by misuse instead of bugs
	ExtendedLogLevel = "development"
)
View Source
var (
	TimeoutMutex           = "false"
	TimeoutMutexBoolean, _ = strconv.ParseBool(TimeoutMutex)
)
View Source
var DebugPaymentE2E = "" // using "debug_payment_e2e" build option, this string will be "debug_payment_e2e"

Functions

func AppendUniqueIdentifier

func AppendUniqueIdentifier(ctx context.Context, guid uint64) context.Context

func Deserialize

func Deserialize(raw []byte, data any)

func FormatLongString

func FormatLongString(msg string, maxCharacters int) string

func FormatStringerList

func FormatStringerList[T fmt.Stringer](description string, listToPrint []T, separator string) string

func GenerateUniqueIdentifier

func GenerateUniqueIdentifier() uint64

func GetUniqueIdentifier

func GetUniqueIdentifier(ctx context.Context) (guid uint64, found bool)

func IsBech32Address

func IsBech32Address(addr string) bool

func IsMiddleOfMonthPassed

func IsMiddleOfMonthPassed(date time.Time) bool

func IsTraceLogLevelEnabled

func IsTraceLogLevelEnabled() bool

func LavaFormatDebug

func LavaFormatDebug(description string, attributes ...Attribute) error

func LavaFormatError

func LavaFormatError(description string, err error, attributes ...Attribute) error

func LavaFormatFatal

func LavaFormatFatal(description string, err error, attributes ...Attribute)

func LavaFormatInfo

func LavaFormatInfo(description string, attributes ...Attribute) error

func LavaFormatLog

func LavaFormatLog(description string, err error, attributes []Attribute, severity uint) error

func LavaFormatPanic

func LavaFormatPanic(description string, err error, attributes ...Attribute)

func LavaFormatProduction

func LavaFormatProduction(description string, err error, attributes ...Attribute) error

depending on the build flag, this log function will log either a warning or an error. the purpose of this function is to fail E2E tests and not allow unexpected behavior to reach main. while in production some errors may occur as consumers / providers might set up their processes in the wrong way. in test environment we dont expect to have these errors and if they occur we would like to fail the test.

func LavaFormatTrace

func LavaFormatTrace(description string, attributes ...Attribute) error

func LavaFormatWarning

func LavaFormatWarning(description string, err error, attributes ...Attribute) error

func LogLavaEvent

func LogLavaEvent(ctx sdk.Context, logger log.Logger, name string, attributes map[string]string, description string)

func Max

func Max[T constraints.Ordered](x, y T) T

func Min

func Min[T constraints.Ordered](x, y T) T

func NextMonth

func NextMonth(date time.Time) time.Time

NextMonth returns the date of the same day next month (assumes UTC), adjusting for end-of-months differences if needed.

func ParseCLIAddress

func ParseCLIAddress(clientCtx client.Context, address string) (string, error)

ParseCLIAddress is used to parse address arguments from CLI. If the address is Bech32 the function simply returns the argument. If it's not, it tries to fetch it from the keyring

func RollingLoggerSetup

func RollingLoggerSetup(rollingLogLevel string, filePath string, maxSize string, maxBackups string, maxAge string, stdFormat string) func()

func Serialize

func Serialize(data any) []byte

func SetGlobalLoggingLevel

func SetGlobalLoggingLevel(logLevel string)

func SetLogLevelFieldName

func SetLogLevelFieldName(fieldName string)

func StrValue

func StrValue(val interface{}) string

func StrValueForLog

func StrValueForLog(val interface{}, key string, idx int, attributes []Attribute) string

func ToHexString

func ToHexString(hash string) string

func ValidateCoins

func ValidateCoins(ctx sdk.Context, denom string, coins sdk.Coin, allowZero bool) error

func WithUniqueIdentifier

func WithUniqueIdentifier(ctx context.Context, guid uint64) context.Context

Types

type Attribute

type Attribute struct {
	Key   string
	Value interface{}
}

func LogAttr

func LogAttr(key string, value interface{}) Attribute

func StringMapToAttributes

func StringMapToAttributes(details map[string]string) []Attribute

type LavaMutex

type LavaMutex struct {
	SecondsLeft int
	// contains filtered or unexported fields
}

func (*LavaMutex) Lock

func (dm *LavaMutex) Lock()

func (*LavaMutex) TryLock

func (dm *LavaMutex) TryLock() (isLocked bool)

func (*LavaMutex) Unlock

func (dm *LavaMutex) Unlock()

type Lockable

type Lockable interface {
	Lock()
	TryLock() bool
	Unlock()
}

type LoggerWrapper

type LoggerWrapper struct {
	LoggerName string
}

this logger is used for any third party loggers that require the logging functionality to be a bit different than the lava logger functionality

func (LoggerWrapper) Debugf

func (lw LoggerWrapper) Debugf(msg string, extraInfo ...interface{})

func (LoggerWrapper) Errorf

func (lw LoggerWrapper) Errorf(msg string, extraInfo ...interface{})

func (LoggerWrapper) Infof

func (lw LoggerWrapper) Infof(msg string, extraInfo ...interface{})

func (LoggerWrapper) Warningf

func (lw LoggerWrapper) Warningf(msg string, extraInfo ...interface{})

Directories

Path Synopsis
common

Jump to

Keyboard shortcuts

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