diff --git a/simulators/ethereum/engine/client/hive_rpc/hive_rpc.go b/simulators/ethereum/engine/client/hive_rpc/hive_rpc.go index d055d1d346..2f2d8c77ab 100644 --- a/simulators/ethereum/engine/client/hive_rpc/hive_rpc.go +++ b/simulators/ethereum/engine/client/hive_rpc/hive_rpc.go @@ -7,6 +7,8 @@ import ( "math/big" "net" "net/http" + "os" + "strconv" "strings" "sync" "time" @@ -108,10 +110,12 @@ func (s HiveRPCEngineStarter) StartClient(T *hivesim.T, testContext context.Cont if err := CheckEthEngineLive(c); err != nil { return nil, fmt.Errorf("Engine/Eth ports were never open for client: %v", err) } + hiveLogLevel, _ := strconv.Atoi(os.Getenv("HIVE_LOGLEVEL")) ec := NewHiveRPCEngineClient(c, enginePort, ethPort, jwtSecret, ttd, &helper.LoggingRoundTrip{ - Logger: T, - ID: c.Container, - Inner: http.DefaultTransport, + Logger: T, + ID: c.Container, + Inner: http.DefaultTransport, + LogLevel: hiveLogLevel, }) return ec, nil } diff --git a/simulators/ethereum/engine/helper/helper.go b/simulators/ethereum/engine/helper/helper.go index 349a732b4c..aaf040669c 100644 --- a/simulators/ethereum/engine/helper/helper.go +++ b/simulators/ethereum/engine/helper/helper.go @@ -38,9 +38,10 @@ type LogF interface { } type LoggingRoundTrip struct { - Logger LogF - ID string - Inner http.RoundTripper + Logger LogF + ID string + Inner http.RoundTripper + LogLevel int } const MAX_LOG_BYTES = 1024 * 4 @@ -53,7 +54,8 @@ func (rt *LoggingRoundTrip) RoundTrip(req *http.Request) (*http.Response, error) return nil, err } reqLogBytes := bytes.TrimSpace(reqBytes[:]) - if len(reqLogBytes) > MAX_LOG_BYTES { + reqTrimLogs := len(reqLogBytes) > MAX_LOG_BYTES && rt.LogLevel <= 3 + if reqTrimLogs { rt.Logger.Logf(">> (%s) %s... (Log trimmed)", rt.ID, reqLogBytes[:MAX_LOG_BYTES]) } else { rt.Logger.Logf(">> (%s) %s", rt.ID, reqLogBytes) @@ -76,7 +78,9 @@ func (rt *LoggingRoundTrip) RoundTrip(req *http.Request) (*http.Response, error) respCopy := *resp respCopy.Body = io.NopCloser(bytes.NewReader(respBytes)) respLogBytes := bytes.TrimSpace(respBytes[:]) - if len(respLogBytes) > MAX_LOG_BYTES { + + respTrimLogs := len(respLogBytes) > MAX_LOG_BYTES && rt.LogLevel <= 3 + if respTrimLogs { rt.Logger.Logf("<< (%s) %s... (Log trimmed)", rt.ID, respLogBytes[:MAX_LOG_BYTES]) } else { rt.Logger.Logf("<< (%s) %s", rt.ID, respLogBytes)