-
Notifications
You must be signed in to change notification settings - Fork 326
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
Allow overriding tracing filter with RUST_LOG
env var
#1896
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left 2 questions, nothing serious.
relayer-cli/src/components.rs
Outdated
.unwrap(); | ||
fn build_tracing_filter(log_level: LogLevel) -> Result<EnvFilter, FrameworkError> { | ||
let directive = std::env::var(HERMES_LOG_VAR).unwrap_or_else(|_| { | ||
let target_crates = ["ibc_relayer", "ibc_relayer_cli"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see here we're using RUST_LOG
not only to replace the log level, but also the crates/modules. Can we give an example on how we're supposed to use RUST_LOG
to overwrite the tracing parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, using RUST_LOG
will override everything. I'll add an example, perhaps something like:
RUST_LOG=tendermint_rpc=debug,ibc_relayer=info,ibc_relayer_cli=info hermes start
|
||
use crate::config::Error; | ||
|
||
/// The name of the environment variable through which one can override | ||
/// the tracing filter built in [`build_tracing_filter`]. | ||
const HERMES_LOG_VAR: &str = "RUST_LOG"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recall the integration tests framework making use of RUST_LOG
, eg in cargo test
. Would just like to flag that -- is there any interference between this approach and the pre-existing support for RUST_LOG
in cargo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logs from the integration tests look fine to me: https://github.com/informalsystems/ibc-rs/runs/5272869928?check_suite_focus=true (modulo some doc tests failures, unrelated to this PR and best fixed elsewhere)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, just to clarify, cargo test
does not care itself about RUST_LOG
but the integration tests themselves do, cf. https://github.com/informalsystems/ibc-rs/blob/8329d856844df30651f68a25ca5c5db4addbaa2b/tools/integration-test/src/bootstrap/single.rs#L75
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What the test suite does is look at the RUST_LOG
env variable, and then sets the log_level
property in config.toml
to that. If the test suite is only ever run with RUST_LOG=info/trace/debug/error/warn
then everything should work as expected with no change in the output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, just to clarify,
cargo test
does not care itself aboutRUST_LOG
but the integration tests themselves do, cf.
Thanks for clarifying that! This part wasn't obvious to me.
@@ -33,7 +33,7 @@ impl Runnable for StartCmd { | |||
let config = (*app_config()).clone(); | |||
let config = Arc::new(RwLock::new(config)); | |||
|
|||
let supervisor_handle = make_supervisor::<ProdChainHandle>(config.clone(), self.full_scan) | |||
let supervisor_handle = make_supervisor::<ProdChainHandle>(config, self.full_scan) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Less cloning of massive data structures, good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it was just cloning an Arc
though, so it should have just consisted of incrementing a reference count.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It likely does not matter in the startup code, but in general coercing an Arc
to a reference is still cheaper than atomically incrementing a ref count.
…`RUST_LOG` is set Co-authored-by: Mikhail Zabaluev <mikhail@informal.systems>
Co-authored-by: Mikhail Zabaluev <mikhail@informal.systems>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, but I still don't see any documentation on how to use RUST_LOG
. Please remember to add that either in guide (release PR) or here.
|
||
use crate::config::Error; | ||
|
||
/// The name of the environment variable through which one can override | ||
/// the tracing filter built in [`build_tracing_filter`]. | ||
const HERMES_LOG_VAR: &str = "RUST_LOG"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, just to clarify,
cargo test
does not care itself aboutRUST_LOG
but the integration tests themselves do, cf.
Thanks for clarifying that! This part wasn't obvious to me.
…ems#1896) Closes: informalsystems#1895 With this PR, one can set the `RUST_LOG` variable to `tendermint_rpc=debug,ibc_relayer=info,ibc_relayer_cli=info` in order to enable debug output for `tendermint-rpc` and info output for the relayer. ```shell RUST_LOG=tendermint_rpc=debug,ibc_relayer=info,ibc_relayer_cli=info hermes start ``` --- * Allow overriding tracing filter with `RUST_LOG` env var * Fix warning * Add changelog entry * Rename `log_level` to `default_level` as the parameter is ignored if `RUST_LOG` is set Co-authored-by: Mikhail Zabaluev <mikhail@informal.systems> * Better log message Co-authored-by: Mikhail Zabaluev <mikhail@informal.systems> * Small refactor Co-authored-by: Mikhail Zabaluev <mikhail@informal.systems>
Closes: #1895
Usage
With this PR, one can set the
RUST_LOG
variable totendermint_rpc=debug,ibc_relayer=info,ibc_relayer_cli=info
in order to enable debug output fortendermint-rpc
and info output for the relayer.PR author checklist:
unclog
.docs/
).Reviewer checklist:
Files changed
in the GitHub PR explorer.