Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward logging directives to Polkadot workers #6534

Merged
merged 3 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading