Skip to content

Commit

Permalink
fix: update trace logging to include bootloader (#309)
Browse files Browse the repository at this point in the history
* fix: display trace logs from bootloader in logs filter

* fix: lint
  • Loading branch information
MexicanAce authored Jul 2, 2024
1 parent 1afa81a commit 6c5d552
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <hello@matterlabs.dev>"]
homepage = "https://zksync.io/"
Expand Down
7 changes: 5 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
24 changes: 11 additions & 13 deletions src/observability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,20 @@ impl From<LogLevel> for LevelFilter {
/// A sharable reference to the observability stack.
#[derive(Debug, Default, Clone)]
pub struct Observability {
binary_name: String,
binary_names: Vec<String>,
reload_handle: Option<reload::Handle<EnvFilter, Registry>>,
}

impl Observability {
/// Initialize the tracing subscriber.
pub fn init(
binary_name: String,
binary_names: Vec<String>,
log_level_filter: LevelFilter,
log_file: File,
) -> Result<Self, anyhow::Error> {
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 =
Expand Down Expand Up @@ -92,19 +90,19 @@ impl Observability {
.init();

Ok(Self {
binary_name,
binary_names,
reload_handle: Some(reload_handle),
})
}

/// 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)?;
Expand Down
2 changes: 1 addition & 1 deletion test_endpoints.http
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}

###
Expand Down

0 comments on commit 6c5d552

Please sign in to comment.