Skip to content

Commit

Permalink
fix env parse log.Level type
Browse files Browse the repository at this point in the history
  • Loading branch information
huangzhiran committed Oct 1, 2024
1 parent 442a817 commit 3093b69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/sequencer/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
BootNodeMultiAddr: "/dns4/bootnode-0.testnet.iotex.one/tcp/4689/ipfs/12D3KooWFnaTYuLo8Mkbm3wzaWHtUuaxBRe24Uiopu15Wr5EhD3o",
IoTeXChainID: 2,
ChainEndpoint: "https://babel-api.testnet.iotex.io",
ProverContractAddr: "0x39d95173C92aadcD47184f770c4a059D8Be66686",
ProverContractAddr: "0xD7B23d74A662Bb8b1d0e98C333641405bE406523",
LocalDBDir: "./local_db",
BeginningBlockNumber: 28000000,
env: "TESTNET",
Expand Down
8 changes: 7 additions & 1 deletion util/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package env

import (
"fmt"
"log/slog"
"reflect"
"strings"

Expand Down Expand Up @@ -46,7 +47,12 @@ func ParseEnv(c any) error {
case reflect.String:
fv.Set(reflect.ValueOf(viper.GetString(key)))
case reflect.Int:
fv.Set(reflect.ValueOf(viper.GetInt(key)))
if fi.Type == reflect.TypeOf(slog.Level(0)) {
level := slog.Level(viper.GetInt(key))
fv.Set(reflect.ValueOf(level))
} else {
fv.Set(reflect.ValueOf(viper.GetInt(key)))
}
case reflect.Uint64:
fv.Set(reflect.ValueOf(viper.GetUint64(key)))
}
Expand Down

0 comments on commit 3093b69

Please sign in to comment.