Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

sc-tracing may not print log in some case after the tracing-log update to v0.1.3 with feature interest-cache #11691

@atenjin

Description

@atenjin

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions