Skip to content

Commit

Permalink
Forward logging directives to Polkadot workers
Browse files Browse the repository at this point in the history
This pull request forward all the logging directives given to the node via `RUST_LOG` or `-l` to the workers, instead of only forwarding `RUST_LUG`.
  • Loading branch information
bkchr committed Nov 19, 2024
1 parent b71bd53 commit d620d9c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions polkadot/node/core/pvf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ polkadot-node-primitives = { workspace = true, default-features = true }
polkadot-node-subsystem = { workspace = true, default-features = true }
polkadot-primitives = { workspace = true, default-features = true }

sc-tracing = { workspace = true }
sp-core = { workspace = true, default-features = true }
sp-maybe-compressed-blob = { optional = true, workspace = true, default-features = true }
polkadot-node-core-pvf-prepare-worker = { optional = true, workspace = true, default-features = true }
Expand Down
6 changes: 2 additions & 4 deletions polkadot/node/core/pvf/src/worker_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,8 @@ impl WorkerHandle {
// Clear all env vars from the spawned process.
let mut command = process::Command::new(program.as_ref());
command.env_clear();
// Add back any env vars we want to keep.
if let Ok(value) = std::env::var("RUST_LOG") {
command.env("RUST_LOG", value);
}

command.env("RUST_LOG", sc_tracing::logging::get_directives().join(","));

let mut child = command
.args(extra_args)
Expand Down
7 changes: 6 additions & 1 deletion substrate/client/tracing/src/logging/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,19 @@ pub(crate) fn add_default_directives(directives: &str) {
add_directives(directives);
}

/// Add directives to current directives
/// Add directives to current directives.
pub fn add_directives(directives: &str) {
CURRENT_DIRECTIVES
.get_or_init(|| Mutex::new(Vec::new()))
.lock()
.push(directives.to_owned());
}

/// Returns the current directives.
pub fn get_directives() -> Vec<String> {
CURRENT_DIRECTIVES.get_or_init(|| Mutex::new(Vec::new())).lock().clone()
}

/// Parse `Directive` and add to default directives if successful.
///
/// Ensures the supplied directive will be restored when resetting the log filter.
Expand Down

0 comments on commit d620d9c

Please sign in to comment.