From 6c5d5524bcc3bd48e471261fa81ad0073e3b5851 Mon Sep 17 00:00:00 2001 From: Nicolas Villanueva Date: Tue, 2 Jul 2024 13:01:41 +0100 Subject: [PATCH] fix: update trace logging to include bootloader (#309) * fix: display trace logs from bootloader in logs filter * fix: lint --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/main.rs | 7 +++++-- src/observability.rs | 24 +++++++++++------------- test_endpoints.http | 2 +- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e0abea38..b5469c4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1751,7 +1751,7 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "era_test_node" -version = "0.1.0-alpha.23" +version = "0.1.0-alpha.24" dependencies = [ "anyhow", "bigdecimal", diff --git a/Cargo.toml b/Cargo.toml index 63e66b09..1a88c3d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "era_test_node" -version = "0.1.0-alpha.23" +version = "0.1.0-alpha.24" edition = "2018" authors = ["The Matter Labs Team "] homepage = "https://zksync.io/" diff --git a/src/main.rs b/src/main.rs index 0130af5b..285b04c7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -323,8 +323,11 @@ async fn main() -> anyhow::Result<()> { let log_file = File::create(opt.log_file_path)?; // Initialize the tracing subscriber - let observability = - Observability::init(String::from("era_test_node"), log_level_filter, log_file)?; + let observability = Observability::init( + vec!["era_test_node".into(), "multivm".into()], + log_level_filter, + log_file, + )?; if matches!(opt.dev_system_contracts, DevSystemContracts::Local) { if let Some(path) = env::var_os("ZKSYNC_HOME") { diff --git a/src/observability.rs b/src/observability.rs index ec3039b6..bcd32176 100644 --- a/src/observability.rs +++ b/src/observability.rs @@ -45,22 +45,20 @@ impl From for LevelFilter { /// A sharable reference to the observability stack. #[derive(Debug, Default, Clone)] pub struct Observability { - binary_name: String, + binary_names: Vec, reload_handle: Option>, } impl Observability { /// Initialize the tracing subscriber. pub fn init( - binary_name: String, + binary_names: Vec, log_level_filter: LevelFilter, log_file: File, ) -> Result { - let filter = Self::parse_filter(&format!( - "{}={}", - binary_name, - format!("{log_level_filter}").to_lowercase() - ))?; + let joined_filter = binary_names + .join(format!("={},", log_level_filter.to_string().to_lowercase()).as_str()); + let filter = Self::parse_filter(&joined_filter)?; let (filter, reload_handle) = reload::Layer::new(filter); let timer_format = @@ -92,7 +90,7 @@ impl Observability { .init(); Ok(Self { - binary_name, + binary_names, reload_handle: Some(reload_handle), }) } @@ -100,11 +98,11 @@ impl Observability { /// Set the log level for the binary. pub fn set_log_level(&self, level: LogLevel) -> Result<(), anyhow::Error> { let level = LevelFilter::from(level); - let new_filter = Self::parse_filter(&format!( - "{}={}", - self.binary_name, - format!("{level}").to_lowercase() - ))?; + let new_filter = Self::parse_filter( + &self + .binary_names + .join(format!("={},", level.to_string().to_lowercase()).as_str()), + )?; if let Some(handle) = &self.reload_handle { handle.modify(|filter| *filter = new_filter)?; diff --git a/test_endpoints.http b/test_endpoints.http index c38792c5..60c8a14b 100644 --- a/test_endpoints.http +++ b/test_endpoints.http @@ -821,7 +821,7 @@ content-type: application/json "jsonrpc": "2.0", "id": "1", "method": "config_setLogging", - "params": ["era_test_node=info,hyper=debug"] + "params": ["era_test_node=trace,multivm=trace"] } ###