Skip to content

Commit

Permalink
Forward logging directives to Polkadot workers (#6534)
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_LOG`.

---------

Co-authored-by: GitHub Action <action@github.com>
  • Loading branch information
bkchr and actions-user authored Nov 19, 2024
1 parent 09757a4 commit cccf341
Show file tree
Hide file tree
Showing 5 changed files with 20 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
10 changes: 10 additions & 0 deletions prdoc/pr_6534.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: Forward logging directives to Polkadot workers
doc:
- audience: Node Dev
description: |-
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_LOG`.
crates:
- name: polkadot-node-core-pvf
bump: patch
- name: sc-tracing
bump: patch
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 cccf341

Please sign in to comment.