mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Yeet env_logger into the sun (#7872)
- Remove explicit `env_logger` usage from `state_processing` tests and `lcli`. - Set up tracing correctly for `lcli` (I've checked that we can see logs after this change). - I didn't do anything to set up logging for the `state_processing` tests, as these are rarely run manually (they never fail). We could add `test_logger` in there on an as-needed basis.
This commit is contained in:
46
Cargo.lock
generated
46
Cargo.lock
generated
@@ -709,17 +709,6 @@ dependencies = [
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi 0.1.19",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "auto_impl"
|
||||
version = "0.5.0"
|
||||
@@ -2743,19 +2732,6 @@ dependencies = [
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"humantime",
|
||||
"log",
|
||||
"regex",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "environment"
|
||||
version = "0.1.2"
|
||||
@@ -4054,15 +4030,6 @@ version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.3.9"
|
||||
@@ -5058,7 +5025,6 @@ dependencies = [
|
||||
"clap",
|
||||
"clap_utils",
|
||||
"deposit_contract",
|
||||
"env_logger 0.9.3",
|
||||
"environment",
|
||||
"eth2",
|
||||
"eth2_network_config",
|
||||
@@ -7491,7 +7457,7 @@ version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6"
|
||||
dependencies = [
|
||||
"env_logger 0.8.4",
|
||||
"env_logger",
|
||||
"log",
|
||||
"rand 0.8.5",
|
||||
]
|
||||
@@ -8961,7 +8927,6 @@ dependencies = [
|
||||
"beacon_chain",
|
||||
"bls",
|
||||
"derivative",
|
||||
"env_logger 0.9.3",
|
||||
"ethereum_hashing",
|
||||
"ethereum_ssz",
|
||||
"ethereum_ssz_derive",
|
||||
@@ -9262,15 +9227,6 @@ dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "terminal_size"
|
||||
version = "0.4.2"
|
||||
|
||||
@@ -136,7 +136,6 @@ dirs = "3"
|
||||
discv5 = { version = "0.9", features = ["libp2p"] }
|
||||
doppelganger_service = { path = "validator_client/doppelganger_service" }
|
||||
either = "1.9"
|
||||
env_logger = "0.9"
|
||||
environment = { path = "lighthouse/environment" }
|
||||
eth2 = { path = "common/eth2" }
|
||||
eth2_config = { path = "common/eth2_config" }
|
||||
|
||||
@@ -41,5 +41,4 @@ types = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
beacon_chain = { workspace = true }
|
||||
env_logger = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
|
||||
@@ -3,13 +3,10 @@ use crate::per_epoch_processing::process_epoch;
|
||||
use beacon_chain::test_utils::BeaconChainHarness;
|
||||
use beacon_chain::types::{EthSpec, MinimalEthSpec};
|
||||
use bls::{FixedBytesExtended, Hash256};
|
||||
use env_logger::{Builder, Env};
|
||||
use types::Slot;
|
||||
|
||||
#[tokio::test]
|
||||
async fn runs_without_error() {
|
||||
Builder::from_env(Env::default().default_filter_or("error")).init();
|
||||
|
||||
let harness = BeaconChainHarness::builder(MinimalEthSpec)
|
||||
.default_spec()
|
||||
.deterministic_keypairs(8)
|
||||
|
||||
@@ -20,7 +20,6 @@ bls = { workspace = true }
|
||||
clap = { workspace = true }
|
||||
clap_utils = { workspace = true }
|
||||
deposit_contract = { workspace = true }
|
||||
env_logger = { workspace = true }
|
||||
environment = { workspace = true }
|
||||
eth2 = { workspace = true }
|
||||
eth2_network_config = { workspace = true }
|
||||
|
||||
@@ -18,12 +18,10 @@ use parse_ssz::run_parse_ssz;
|
||||
use std::path::PathBuf;
|
||||
use std::process;
|
||||
use std::str::FromStr;
|
||||
use tracing_subscriber::filter::LevelFilter;
|
||||
use tracing_subscriber::{filter::LevelFilter, layer::SubscriberExt, util::SubscriberInitExt};
|
||||
use types::{EthSpec, EthSpecId};
|
||||
|
||||
fn main() {
|
||||
env_logger::init();
|
||||
|
||||
let matches = Command::new("Lighthouse CLI Tool")
|
||||
.version(lighthouse_version::VERSION)
|
||||
.display_order(0)
|
||||
@@ -653,7 +651,7 @@ fn main() {
|
||||
}
|
||||
|
||||
fn run<E: EthSpec>(env_builder: EnvironmentBuilder<E>, matches: &ArgMatches) -> Result<(), String> {
|
||||
let (env_builder, _file_logging_layer, _stdout_logging_layer, _sse_logging_layer_opt) =
|
||||
let (env_builder, file_logging_layer, stdout_logging_layer, _sse_logging_layer_opt) =
|
||||
env_builder
|
||||
.multi_threaded_tokio_runtime()
|
||||
.map_err(|e| format!("should start tokio runtime: {:?}", e))?
|
||||
@@ -682,6 +680,18 @@ fn run<E: EthSpec>(env_builder: EnvironmentBuilder<E>, matches: &ArgMatches) ->
|
||||
.build()
|
||||
.map_err(|e| format!("should build env: {:?}", e))?;
|
||||
|
||||
let mut logging_layers = vec![file_logging_layer];
|
||||
if let Some(stdout) = stdout_logging_layer {
|
||||
logging_layers.push(stdout);
|
||||
}
|
||||
let logging_result = tracing_subscriber::registry()
|
||||
.with(logging_layers)
|
||||
.try_init();
|
||||
|
||||
if let Err(e) = logging_result {
|
||||
eprintln!("Failed to initialize logger: {e}");
|
||||
}
|
||||
|
||||
// Determine testnet-dir path or network name depending on CLI flags.
|
||||
let (testnet_dir, network_name) =
|
||||
if let Some(testnet_dir) = parse_optional::<PathBuf>(matches, "testnet-dir")? {
|
||||
|
||||
Reference in New Issue
Block a user