From 459f4e586e75de837257215049f7d2fb9f60626a Mon Sep 17 00:00:00 2001 From: "liquan.eth" Date: Mon, 27 Apr 2026 16:36:55 +0800 Subject: [PATCH] delete repeated STATELESS_VALIDATOR_LOG_* --- README.md | 6 +++--- bin/stateless-validator/src/app.rs | 6 +----- crates/stateless-common/src/logging.rs | 25 ------------------------- 3 files changed, 4 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 7ff225ec..c71dfd2a 100644 --- a/README.md +++ b/README.md @@ -107,10 +107,10 @@ Each command-line flag has an equivalent environment variable: - `STATELESS_VALIDATOR_METRICS_PORT` → `--metrics-port` **Logging Configuration:** -- `STATELESS_VALIDATOR_LOG_FILE_DIRECTORY`: Directory for log files; enables file logging when set. +- `STATELESS_LOG_FILE_DIRECTORY`: Directory for log files; enables file logging when set. Files rotate daily as `stateless-validator.log.YYYY-MM-DD`. -- `STATELESS_VALIDATOR_LOG_FILE`: Log level for file output (debug|info|warn|error, default: debug) -- `STATELESS_VALIDATOR_LOG_STDOUT`: Log level for console output (debug|info|warn|error, default: info) +- `STATELESS_LOG_FILE`: Log level for file output (debug|info|warn|error, default: debug) +- `STATELESS_LOG_STDOUT`: Log level for console output (debug|info|warn|error, default: info) Command-line arguments take precedence over environment variables. diff --git a/bin/stateless-validator/src/app.rs b/bin/stateless-validator/src/app.rs index d09bb1b2..dad2d575 100644 --- a/bin/stateless-validator/src/app.rs +++ b/bin/stateless-validator/src/app.rs @@ -7,10 +7,7 @@ use alloy_primitives::BlockHash; use alloy_rpc_types_eth::BlockId; use clap::Parser; use eyre::Result; -use stateless_common::{ - BackoffPolicy, RpcClient, RpcClientConfig, - logging::{LogArgs, migrate_legacy_env_vars}, -}; +use stateless_common::{BackoffPolicy, RpcClient, RpcClientConfig, logging::LogArgs}; use stateless_core::{ ChainStore, ContractStore, GenesisStore, chain_spec::ChainSpec, db::BlockMeta, }; @@ -153,7 +150,6 @@ pub struct CommandLineArgs { /// validator DB, loads or initializes the chain spec + anchor, then hands off to /// [`workers::run_with_signals`]. pub async fn run() -> Result<()> { - migrate_legacy_env_vars(); let args = CommandLineArgs::parse(); let _log_guard = args.log.init_tracing()?; let start = std::time::Instant::now(); diff --git a/crates/stateless-common/src/logging.rs b/crates/stateless-common/src/logging.rs index 16c8d8a9..77d6a12f 100644 --- a/crates/stateless-common/src/logging.rs +++ b/crates/stateless-common/src/logging.rs @@ -149,31 +149,6 @@ fn build_file_writer( Ok((non_blocking, guard)) } -/// Migrate legacy `STATELESS_VALIDATOR_LOG_*` env vars to the new `STATELESS_LOG_*` names. -/// Only copies when the new var is not already set, so the new name always takes precedence. -/// -/// Must be called **before** `clap::Parser::parse()` so that clap sees the migrated values. -/// -/// # Safety -/// -/// This mutates process-global environment state. Call it early in `main()` before -/// spawning any threads or starting async runtimes. -pub fn migrate_legacy_env_vars() { - const LEGACY_MAP: &[(&str, &str)] = &[ - ("STATELESS_VALIDATOR_LOG_STDOUT", "STATELESS_LOG_STDOUT"), - ("STATELESS_VALIDATOR_LOG_FILE", "STATELESS_LOG_FILE"), - ("STATELESS_VALIDATOR_LOG_FILE_DIRECTORY", "STATELESS_LOG_FILE_DIRECTORY"), - ]; - for &(old, new) in LEGACY_MAP { - if std::env::var(new).is_err() && - let Ok(val) = std::env::var(old) - { - // SAFETY: called before any multithreaded runtime is started. - unsafe { std::env::set_var(new, val) }; - } - } -} - impl LogArgs { /// Initialize the global tracing subscriber based on the current configuration. ///