diff --git a/CHANGELOG.md b/CHANGELOG.md index 50cad37ec..bf9c2699f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added verification to ensure CARTESI_BLOCKCHAIN_ID matches the id returned from the Ethereum node - Added `CARTESI_EXPERIMENTAL_SERVER_MANAGER_BYPASS_LOG` env var to allow `server-manager` output to bypass all log configuration +- Added `CARTESI_EXPERIMENTAL_DISABLE_CONFIG_LOG` env var to disable log entries related to the node's configuration ## Changed diff --git a/docs/config.md b/docs/config.md index 74b766674..a73c1008f 100644 --- a/docs/config.md +++ b/docs/config.md @@ -131,6 +131,13 @@ Address of the InputBox contract. * **Type:** `string` +## `CARTESI_EXPERIMENTAL_DISABLE_CONFIG_LOG` + +Disables all log entries related to the node's configuration + +* **Type:** `bool` +* **Default:** `"false"` + ## `CARTESI_EXPERIMENTAL_SERVER_MANAGER_BYPASS_LOG` When enabled, prints server-manager output to stdout and stderr directly. diff --git a/internal/config/config.go b/internal/config/config.go index 815b0019c..71ac93e60 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -13,6 +13,7 @@ package config import ( "fmt" + "io" "log" "os" "strconv" @@ -99,6 +100,9 @@ var configLogger = log.New(os.Stdout, "CONFIG ", log.LstdFlags) func init() { cache.values = make(map[string]string) + if GetCartesiExperimentalDisableConfigLog() { + configLogger.SetOutput(io.Discard) + } } // Reads the value of an environment variable (loads from a cached value when possible). diff --git a/internal/config/generate/Config.toml b/internal/config/generate/Config.toml index 9ab368aac..feacbd25d 100644 --- a/internal/config/generate/Config.toml +++ b/internal/config/generate/Config.toml @@ -243,4 +243,11 @@ default = "false" go-type = "bool" description = """ When enabled, prints server-manager output to stdout and stderr directly. -All other log configurations are ignored.""" \ No newline at end of file +All other log configurations are ignored.""" + +[experimental.CARTESI_EXPERIMENTAL_DISABLE_CONFIG_LOG] +default = "false" +go-type = "bool" +redact = true +description = """ +Disables all log entries related to the node's configuration""" \ No newline at end of file diff --git a/internal/config/get.go b/internal/config/get.go index 436672f3b..b5cc5d570 100644 --- a/internal/config/get.go +++ b/internal/config/get.go @@ -99,6 +99,11 @@ func GetCartesiContractsInputBoxAddress() string { return v } +func GetCartesiExperimentalDisableConfigLog() bool { + v := get("CARTESI_EXPERIMENTAL_DISABLE_CONFIG_LOG", "false", true, true, toBool) + return v +} + func GetCartesiExperimentalServerManagerBypassLog() bool { v := get("CARTESI_EXPERIMENTAL_SERVER_MANAGER_BYPASS_LOG", "false", true, false, toBool) return v