From b0cff76a6e89110dec569a282116b79f4e0fbe09 Mon Sep 17 00:00:00 2001 From: Victor Yves Crispim Date: Mon, 11 Mar 2024 16:33:46 -0300 Subject: [PATCH 1/3] feat: allow server-manager to bypass log config A workaround so Sunodo can display only the application output on its log # Conflicts: # CHANGELOG.md --- CHANGELOG.md | 3 ++- docs/config.md | 8 ++++++++ internal/config/generate/Config.toml | 6 ++++++ internal/config/get.go | 5 +++++ internal/services/server-manager.go | 10 ++++++++-- 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77d8bf6f7..880f9dacb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,12 +6,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## Unreleased +## [Unreleased] ### Added - Added verification to ensure CARTESI_BLOCKCHAIN_ID matches the id returned from the Ethereum node - Added support for CARTESI_AUTH_PRIVATE_KEY and CARTESI_AUTH_PRIVATE_KEY_FILE +- Added `CARTESI_EXPERIMENTAL_SERVER_MANAGER_BYPASS_LOG` env var to allow `server-manager` output to bypass all log configuration ## Changed diff --git a/docs/config.md b/docs/config.md index 5f8979bba..6898a5555 100644 --- a/docs/config.md +++ b/docs/config.md @@ -147,6 +147,14 @@ Address of the InputBox contract. * **Type:** `string` +## `CARTESI_EXPERIMENTAL_SERVER_MANAGER_BYPASS_LOG` + +When enabled, prints server-manager output to stdout and stderr directly. +All other log configurations are ignored. + +* **Type:** `bool` +* **Default:** `"false"` + ## `CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_ENABLED` When enabled, the node does not start the authority-claimer service and the Redis server. diff --git a/internal/config/generate/Config.toml b/internal/config/generate/Config.toml index 212146fc6..a8b2771a6 100644 --- a/internal/config/generate/Config.toml +++ b/internal/config/generate/Config.toml @@ -256,3 +256,9 @@ go-type = "string" description = """ External Redis endpoint for the node when running in the experimental sunodo validator mode.""" +[experimental.CARTESI_EXPERIMENTAL_SERVER_MANAGER_BYPASS_LOG] +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 diff --git a/internal/config/get.go b/internal/config/get.go index d5d9419bc..7e187d0dd 100644 --- a/internal/config/get.go +++ b/internal/config/get.go @@ -109,6 +109,11 @@ func GetCartesiContractsInputBoxAddress() string { return v } +func GetCartesiExperimentalServerManagerBypassLog() bool { + v := get("CARTESI_EXPERIMENTAL_SERVER_MANAGER_BYPASS_LOG", "false", true, false, toBool) + return v +} + func GetCartesiExperimentalSunodoValidatorEnabled() bool { v := get("CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_ENABLED", "false", true, false, toBool) return v diff --git a/internal/services/server-manager.go b/internal/services/server-manager.go index 086809b2b..9e84f4b14 100644 --- a/internal/services/server-manager.go +++ b/internal/services/server-manager.go @@ -7,6 +7,7 @@ import ( "context" "fmt" "net" + "os" "os/exec" "strconv" "strings" @@ -41,8 +42,13 @@ const waitDelay = 200 * time.Millisecond func (s ServerManager) Start(ctx context.Context, ready chan<- struct{}) error { cmd := exec.CommandContext(ctx, s.Path, s.Args...) cmd.Env = s.Env - cmd.Stderr = newLineWriter(commandLogger{s.Name}) - cmd.Stdout = newLineWriter(commandLogger{s.Name}) + if config.GetCartesiExperimentalServerManagerBypassLog() { + cmd.Stderr = os.Stderr + cmd.Stdout = os.Stdout + } else { + cmd.Stderr = newLineWriter(commandLogger{s.Name}) + cmd.Stdout = newLineWriter(commandLogger{s.Name}) + } // Without a delay, cmd.Wait() will block forever waiting for the I/O pipes // to be closed cmd.WaitDelay = waitDelay From 459049990266a26b269aede05f5070945d1f7eab Mon Sep 17 00:00:00 2001 From: Victor Yves Crispim Date: Wed, 13 Mar 2024 11:58:07 -0300 Subject: [PATCH 2/3] feat: add option to disable configuration logs --- CHANGELOG.md | 1 + docs/config.md | 7 +++++++ internal/config/config.go | 4 ++++ internal/config/generate/Config.toml | 9 ++++++++- internal/config/get.go | 5 +++++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 880f9dacb..6b0f96a9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,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 support for CARTESI_AUTH_PRIVATE_KEY and CARTESI_AUTH_PRIVATE_KEY_FILE - 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 6898a5555..d4027c0a1 100644 --- a/docs/config.md +++ b/docs/config.md @@ -147,6 +147,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 00aa30a86..c0ecbdfc5 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -13,6 +13,7 @@ package config import ( "fmt" + "io" "log" "os" "strconv" @@ -104,6 +105,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 a8b2771a6..269041c3e 100644 --- a/internal/config/generate/Config.toml +++ b/internal/config/generate/Config.toml @@ -261,4 +261,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 7e187d0dd..04be9cbc9 100644 --- a/internal/config/get.go +++ b/internal/config/get.go @@ -109,6 +109,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 From e05e0d954d8c51e093d0769bb04c69489626e790 Mon Sep 17 00:00:00 2001 From: Victor Yves Crispim Date: Wed, 13 Mar 2024 17:04:34 -0300 Subject: [PATCH 3/3] chore: update CHANGELOG --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b0f96a9b..a00082c11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ 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 support for CARTESI_AUTH_PRIVATE_KEY and CARTESI_AUTH_PRIVATE_KEY_FILE + +## [1.3.1] 2024-03-13 + +### Added + - 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 @@ -351,7 +356,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Deprecated mock contracts -[Unreleased]: https://github.com/cartesi/rollups-node/releases/tag/v1.3.0...HEAD +[Unreleased]: https://github.com/cartesi/rollups-node/releases/tag/v1.3.1...HEAD +[1.3.1]: https://github.com/cartesi/rollups-node/releases/tag/v1.3.1 [1.3.0]: https://github.com/cartesi/rollups-node/releases/tag/v1.3.0 [1.2.0]: https://github.com/cartesi/rollups-node/releases/tag/v1.2.0 [1.1.0]: https://github.com/cartesi/rollups-node/releases/tag/v1.1.0