Skip to content

Commit

Permalink
Set log_level madness
Browse files Browse the repository at this point in the history
  • Loading branch information
endline committed Dec 12, 2024
1 parent dbd06b0 commit 4054be5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
23 changes: 22 additions & 1 deletion cmd/audiusd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"encoding/hex"
"log/slog"
"net/http"
"net/http/httputil"
"net/url"
Expand Down Expand Up @@ -30,7 +31,27 @@ func main() {
tlsEnabled := getEnvBool("ENABLE_TLS", false)
storageEnabled := getEnvBool("ENABLE_STORAGE", false)

logger := common.NewLogger(nil)
var slogLevel slog.Level
if logLevel := os.Getenv("audiusd_log_level"); logLevel != "" {
switch logLevel {
case "debug":
slogLevel = slog.LevelDebug
case "info":
slogLevel = slog.LevelInfo
case "warn":
slogLevel = slog.LevelWarn
case "error":
slogLevel = slog.LevelError
default:
slogLevel = slog.LevelWarn
}
} else {
slogLevel = slog.LevelInfo
}

logger := common.NewLogger(&slog.HandlerOptions{
Level: slogLevel,
})

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down
1 change: 1 addition & 0 deletions pkg/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ func setupNode(logger *common.Logger) (*config.Config, *cconfig.Config, error) {

// https://docs.cometbft.com/main/references/config/config.toml#log_level
cometConfig.LogLevel = envConfig.LogLevel
logger.Infof("Setting cometConfig.LogLevel = envConfig.LogLevel: %s, %s", cometConfig.LogLevel, envConfig.LogLevel)

// postgres indexer config
cometConfig.TxIndex.Indexer = "psql"
Expand Down

0 comments on commit 4054be5

Please sign in to comment.