Skip to content

Commit

Permalink
Add Trace log level (#1390)
Browse files Browse the repository at this point in the history
  • Loading branch information
shleikes authored Apr 25, 2024
1 parent 6f6d0e5 commit 1ec3d07
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions utils/lavalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const (
)

const (
LAVA_LOG_DEBUG = iota
LAVA_LOG_TRACE = iota
LAVA_LOG_DEBUG
LAVA_LOG_INFO
LAVA_LOG_WARN
LAVA_LOG_ERROR
Expand All @@ -37,7 +38,7 @@ var (
// if set to production, this will replace some errors to warning that can be caused by misuse instead of bugs
ExtendedLogLevel = "development"
rollingLogLogger = zerolog.New(os.Stderr).Level(zerolog.Disabled) // this is the singleton rolling logger.
globalLogLevel = zerolog.DebugLevel
globalLogLevel = zerolog.TraceLevel
)

type Attribute struct {
Expand Down Expand Up @@ -73,6 +74,8 @@ func LogLavaEvent(ctx sdk.Context, logger log.Logger, name string, attributes ma

func getLogLevel(logLevel string) zerolog.Level {
switch logLevel {
case "trace":
return zerolog.TraceLevel
case "debug":
return zerolog.DebugLevel
case "info":
Expand Down Expand Up @@ -124,6 +127,8 @@ func RollingLoggerSetup(rollingLogLevel string, filePath string, maxSize string,
switch rollingLogLevel {
case "off":
return func() {} // default is disabled.
case "trace":
logLevel = zerolog.TraceLevel
case "debug":
logLevel = zerolog.DebugLevel
case "info":
Expand Down Expand Up @@ -245,6 +250,10 @@ func LavaFormatLog(description string, err error, attributes []Attribute, severi
logEvent = zerologlog.Debug()
rollingLoggerEvent = rollingLogLogger.Debug()
// prefix = "Debug:"
case LAVA_LOG_TRACE:
logEvent = zerologlog.Trace()
rollingLoggerEvent = rollingLogLogger.Trace()
// prefix = "Trace:"
}
output := description
attrStrings := []string{}
Expand Down Expand Up @@ -313,6 +322,10 @@ func LavaFormatDebug(description string, attributes ...Attribute) error {
return LavaFormatLog(description, nil, attributes, LAVA_LOG_DEBUG)
}

func LavaFormatTrace(description string, attributes ...Attribute) error {
return LavaFormatLog(description, nil, attributes, LAVA_LOG_TRACE)
}

func FormatStringerList[T fmt.Stringer](description string, listToPrint []T, separator string) string {
st := ""
for _, printable := range listToPrint {
Expand Down

0 comments on commit 1ec3d07

Please sign in to comment.