From d315605d7d101f723a5c870571848fba50c8c6ae Mon Sep 17 00:00:00 2001 From: Roger <50648015+RogerLamTd@users.noreply.github.com> Date: Tue, 27 Feb 2024 20:42:49 -0800 Subject: [PATCH] fix(flags): fix logger level flags (#575) Co-authored-by: maskpp Co-authored-by: David --- cmd/logger/logger.go | 3 ++- integration_test/entrypoint.sh | 1 + integration_test/test_env.sh | 4 +++- internal/testutils/suite.go | 6 +++++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cmd/logger/logger.go b/cmd/logger/logger.go index 61239e856..4af556d45 100644 --- a/cmd/logger/logger.go +++ b/cmd/logger/logger.go @@ -19,7 +19,8 @@ func InitLogger(c *cli.Context) { glogger.Verbosity(slogVerbosity) log.SetDefault(log.NewLogger(glogger)) } else { - glogger := log.NewGlogHandler(log.NewTerminalHandlerWithLevel(os.Stdout, slogVerbosity, true)) + glogger := log.NewGlogHandler(log.NewTerminalHandler(os.Stdout, true)) + glogger.Verbosity(slogVerbosity) log.SetDefault(log.NewLogger(glogger)) } } diff --git a/integration_test/entrypoint.sh b/integration_test/entrypoint.sh index 437cda73c..34d62122d 100755 --- a/integration_test/entrypoint.sh +++ b/integration_test/entrypoint.sh @@ -41,6 +41,7 @@ check_env "L1_PROPOSER_PRIVATE_KEY" check_env "L1_PROVER_PRIVATE_KEY" check_env "TREASURY" check_env "JWT_SECRET" +check_env "VERBOSITY" RUN_TESTS=${RUN_TESTS:-false} PACKAGE=${PACKAGE:-...} diff --git a/integration_test/test_env.sh b/integration_test/test_env.sh index aaa5f2d97..9df256c4c 100755 --- a/integration_test/test_env.sh +++ b/integration_test/test_env.sh @@ -22,6 +22,7 @@ export L1_PROPOSER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5ef export L2_SUGGESTED_FEE_RECIPIENT=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 export L1_PROVER_PRIVATE_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d export TREASURY=0x1670010000000000000000000000000000010001 +export VERBOSITY=3 # show the integration test environment variables. # L1_BEACON_HTTP_ENDPOINT=$L1_BEACON_HTTP_ENDPOINT @@ -46,4 +47,5 @@ L1_SECURITY_COUNCIL_PRIVATE_KEY=$L1_SECURITY_COUNCIL_PRIVATE_KEY L1_PROPOSER_PRIVATE_KEY=$L1_PROPOSER_PRIVATE_KEY L1_PROVER_PRIVATE_KEY=$L1_PROVER_PRIVATE_KEY TREASURY=$TREASURY -JWT_SECRET=$JWT_SECRET" > integration_test/.env +JWT_SECRET=$JWT_SECRET +VERBOSITY=$VERBOSITY" > integration_test/.env diff --git a/internal/testutils/suite.go b/internal/testutils/suite.go index b5164f08c..461ad8bbb 100644 --- a/internal/testutils/suite.go +++ b/internal/testutils/suite.go @@ -6,6 +6,7 @@ import ( "math/big" "net/url" "os" + "strconv" "github.com/cenkalti/backoff/v4" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -35,7 +36,10 @@ type ClientTestSuite struct { func (s *ClientTestSuite) SetupTest() { utils.LoadEnv() // Default logger - glogger := log.NewGlogHandler(log.NewTerminalHandlerWithLevel(os.Stdout, log.LevelInfo, true)) + ver, err := strconv.Atoi(os.Getenv("VERBOSITY")) + s.Nil(err) + glogger := log.NewGlogHandler(log.NewTerminalHandler(os.Stdout, true)) + glogger.Verbosity(log.FromLegacyLevel(ver)) log.SetDefault(log.NewLogger(glogger)) testAddrPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROPOSER_PRIVATE_KEY")))