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

[CI] Disable runtime logging for benchmarks #1463

Merged
merged 7 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions .gitlab/pipeline/short-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ short-benchmark-polkadot: &short-bench
artifacts: true
variables:
RUNTIME: polkadot
RUNTIME_LOG: off
tags:
- benchmark
script:
Expand Down Expand Up @@ -42,6 +43,7 @@ short-benchmark-westend:
artifacts: true
variables:
RUNTIME_CHAIN: benchmarked-runtime-chain
RUNTIME_LOG: off
tags:
- benchmark
script:
Expand Down
13 changes: 12 additions & 1 deletion substrate/primitives/io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,9 @@ pub trait PanicHandler {
}
}

/// Set a different log level for the runtime instead of using the one from the host.
pub const RUNTIME_LOG_ENV: &str = "RUNTIME_LOG";

/// Interface that provides functions for logging from within the runtime.
#[runtime_interface]
pub trait Logging {
Expand All @@ -1568,8 +1571,16 @@ pub trait Logging {
}
}

/// Returns the max log level used by the host.
/// Returns the max log level for the runtime.
///
/// Uses the host as default log level but can be overwritten with [`RUNTIME_LOG_ENV`].
fn max_level() -> LogLevelFilter {
if let Ok(level) = std::env::var(RUNTIME_LOG_ENV) {
if let Ok(level) = level.parse::<log::LevelFilter>() {
return level.into()
}
}

log::max_level().into()
}
}
Expand Down