mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 04:01:51 +00:00
simulator: Write dependency logs to separate files (#7433)
This PR relates to: - https://github.com/sigp/lighthouse/pull/7199 - -> workspace_filter has been enabled (dependency logging has been disabled) - https://github.com/sigp/lighthouse/pull/7394 - -> file logging has been optionally enabled Building on these, this PR enables dependency logging for the simulators. The logs are written to separate files. The libp2p/discv5 logs: - are saved to the directory specified with `--log-dir` - respects the `RUST_LOG` environment variable for log level configuration
This commit is contained in:
@@ -17,10 +17,11 @@ use std::time::Duration;
|
||||
|
||||
use environment::tracing_common;
|
||||
use tracing_subscriber::prelude::*;
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
|
||||
|
||||
use logging::build_workspace_filter;
|
||||
use tokio::time::sleep;
|
||||
use tracing::Level;
|
||||
use types::{Epoch, EthSpec, MinimalEthSpec};
|
||||
|
||||
const END_EPOCH: u64 = 16;
|
||||
@@ -36,12 +37,13 @@ const SUGGESTED_FEE_RECIPIENT: [u8; 20] =
|
||||
|
||||
#[allow(clippy::large_stack_frames)]
|
||||
pub fn run_basic_sim(matches: &ArgMatches) -> Result<(), String> {
|
||||
let node_count = matches
|
||||
let (_name, subcommand_matches) = matches.subcommand().expect("subcommand");
|
||||
let node_count = subcommand_matches
|
||||
.get_one::<String>("nodes")
|
||||
.expect("missing nodes default")
|
||||
.parse::<usize>()
|
||||
.expect("missing nodes default");
|
||||
let proposer_nodes = matches
|
||||
let proposer_nodes = subcommand_matches
|
||||
.get_one::<String>("proposer-nodes")
|
||||
.unwrap_or(&String::from("0"))
|
||||
.parse::<usize>()
|
||||
@@ -49,23 +51,25 @@ pub fn run_basic_sim(matches: &ArgMatches) -> Result<(), String> {
|
||||
// extra beacon node added with delay
|
||||
let extra_nodes: usize = 1;
|
||||
println!("PROPOSER-NODES: {}", proposer_nodes);
|
||||
let validators_per_node = matches
|
||||
let validators_per_node = subcommand_matches
|
||||
.get_one::<String>("validators-per-node")
|
||||
.expect("missing validators-per-node default")
|
||||
.parse::<usize>()
|
||||
.expect("missing validators-per-node default");
|
||||
let speed_up_factor = matches
|
||||
let speed_up_factor = subcommand_matches
|
||||
.get_one::<String>("speed-up-factor")
|
||||
.expect("missing speed-up-factor default")
|
||||
.parse::<u64>()
|
||||
.expect("missing speed-up-factor default");
|
||||
let log_level = matches
|
||||
let log_level = subcommand_matches
|
||||
.get_one::<String>("debug-level")
|
||||
.expect("missing debug-level");
|
||||
|
||||
let continue_after_checks = matches.get_flag("continue-after-checks");
|
||||
let log_dir = matches.get_one::<String>("log-dir").map(PathBuf::from);
|
||||
let disable_stdout_logging = matches.get_flag("disable-stdout-logging");
|
||||
let continue_after_checks = subcommand_matches.get_flag("continue-after-checks");
|
||||
let log_dir = subcommand_matches
|
||||
.get_one::<String>("log-dir")
|
||||
.map(PathBuf::from);
|
||||
let disable_stdout_logging = subcommand_matches.get_flag("disable-stdout-logging");
|
||||
|
||||
println!("Basic Simulator:");
|
||||
println!(" nodes: {}", node_count);
|
||||
@@ -98,7 +102,7 @@ pub fn run_basic_sim(matches: &ArgMatches) -> Result<(), String> {
|
||||
stdout_logging_layer,
|
||||
file_logging_layer,
|
||||
_sse_logging_layer_opt,
|
||||
_libp2p_discv5_layer,
|
||||
libp2p_discv5_layer,
|
||||
) = tracing_common::construct_logger(
|
||||
LoggerConfig {
|
||||
path: log_dir,
|
||||
@@ -138,6 +142,17 @@ pub fn run_basic_sim(matches: &ArgMatches) -> Result<(), String> {
|
||||
.boxed(),
|
||||
);
|
||||
}
|
||||
if let Some(libp2p_discv5_layer) = libp2p_discv5_layer {
|
||||
logging_layers.push(
|
||||
libp2p_discv5_layer
|
||||
.with_filter(
|
||||
EnvFilter::builder()
|
||||
.with_default_directive(Level::DEBUG.into())
|
||||
.from_env_lossy(),
|
||||
)
|
||||
.boxed(),
|
||||
);
|
||||
}
|
||||
|
||||
if let Err(e) = tracing_subscriber::registry()
|
||||
.with(logging_layers)
|
||||
|
||||
Reference in New Issue
Block a user