Is there an existing issue?
Experiencing problems? Have you tried our Stack Exchange first?
Description of bug
after substrate pr "Turn on logger's interest cache (#11264 )" , the tracing-log has updated to 0.1.3 with the feature interest-cache. but it seems that the upstream crate tracing-log has some bug in 0.1.3, and can not print log when we using sc-tracing in some case. (I do not know why using in substrate there is no problem, but in our project it has....)
Steps to reproduce
the simplified case is like this:
# create a new empty project
cargo new --bin test_tracing
and the test code in main.rs is just like this:
fn main() {
let mut builder = sc_tracing::logging::LoggerBuilder::new("");
builder.with_log_reloading(true);
builder.init();
log::info!("aaaaaaaaaa");
}
and the Cargo.toml is like this:
[dependencies]
log = "0.4"
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19" }
#
# [patch."https://github.com/paritytech/substrate"]
# sc-tracing = { path = "/<my path>/workspace/blockchain/paritytech/substrate/client/tracing" }
then compile and run the code, it can have normal output:
2022-06-17 11:31:50 aaaaaaaaaa
and when I switch the dependency from polkadot-v0.9.19 to polkadot-v0.9.22, it can not work, there is no normal output...
So I check the git history, can ensure the problem is coming from the pr #11264 .
Then I wanna to figure out more thing, so I use a patch to replace the sc-traing, just like the code in the abrove.
[patch."https://github.com/paritytech/substrate"]
sc-tracing = { path = "/<my path>/workspace/blockchain/paritytech/substrate/client/tracing" }
and in my local path, I remove the code in substrate for this part (my local substrate has switch to branch polkadot-v0.9.22):
in client/tracing/src/logging/mod.rs:L160
tracing_log::LogTracer::builder()
.with_max_level(max_level)
// .with_interest_cache(tracing_log::InterestCacheConfig::default())
.init()?;
I remove the line .with_interest_cache(tracing_log::InterestCacheConfig::default()) which is coming from pr #11264
Then I compile it again and run, it also has no output (I do not modify any rust code in main.rs in the test project).
Then I remove the feature in my local substrate's sc-tracing crate:
in client/tracing/Crago.toml:L29
# tracing-log = { version = "0.1.3", features = ["interest-cache"] }
tracing-log = { version = "0.1.3" }
Then I don't do anything for my test project, and re-compile it again, then it can work.
Thus at here, I ensure this problem is coming from the upstream crate tracing-log, and it only appear when the feature interest-cache is opened, even we do not call with_interest_cache in the code...
But I'm still confused for why it work for substrate project? like cumulus, but our project and the test project can appear this problem.
we meet the problem for we are developing a project which the struct is same as cumulus, which also contains a full-node during running, and we start all task base on the runner that is coming from substrate service (https://github.com/paritytech/substrate/blob/master/bin/node-template/node/src/command.rs#L109). The log init at here.
Is there an existing issue?
Experiencing problems? Have you tried our Stack Exchange first?
Description of bug
after substrate pr "Turn on logger's interest cache (#11264 )" , the
tracing-loghas updated to 0.1.3 with the featureinterest-cache. but it seems that the upstream cratetracing-loghas some bug in 0.1.3, and can not print log when we usingsc-tracingin some case. (I do not know why using in substrate there is no problem, but in our project it has....)Steps to reproduce
the simplified case is like this:
# create a new empty project cargo new --bin test_tracingand the test code in main.rs is just like this:
and the Cargo.toml is like this:
then compile and run the code, it can have normal output:
and when I switch the dependency from
polkadot-v0.9.19topolkadot-v0.9.22, it can not work, there is no normal output...So I check the git history, can ensure the problem is coming from the pr #11264 .
Then I wanna to figure out more thing, so I use a patch to replace the
sc-traing, just like the code in the abrove.and in my local path, I remove the code in substrate for this part (my local substrate has switch to branch
polkadot-v0.9.22):in
client/tracing/src/logging/mod.rs:L160I remove the line
.with_interest_cache(tracing_log::InterestCacheConfig::default())which is coming from pr #11264Then I compile it again and run, it also has no output (I do not modify any rust code in main.rs in the test project).
Then I remove the feature in my local substrate's sc-tracing crate:
in
client/tracing/Crago.toml:L29Then I don't do anything for my test project, and re-compile it again, then it can work.
Thus at here, I ensure this problem is coming from the upstream crate
tracing-log, and it only appear when the featureinterest-cacheis opened, even we do not callwith_interest_cachein the code...But I'm still confused for why it work for substrate project? like cumulus, but our project and the test project can appear this problem.
we meet the problem for we are developing a project which the struct is same as cumulus, which also contains a full-node during running, and we start all task base on the
runnerthat is coming from substrate service (https://github.com/paritytech/substrate/blob/master/bin/node-template/node/src/command.rs#L109). The log init at here.