Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
6 changes: 1 addition & 5 deletions bin/stateless-validator/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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();
Expand Down
25 changes: 0 additions & 25 deletions crates/stateless-common/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
Loading