Use Substrate's built-in sp-tracing!
https://www.youtube.com/watch?v=ZSipV1LLUzM
add sp-tracing in the pallet cargo file under dev dependencies:
sp-tracing = { version = "6.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
use it in your code
use frame_support::{log::{info, warn}, .. };
info!("info num: {:?}", num);
warn!("warn num: {:?}", num);
in your pallet/mock:
pub fn new_test_ext() -> sp_io::TestExternalities {
sp_tracing::try_init_simple();// Add this line
system::GenesisConfig::default().build_storage::<Test>().unwrap().into()
}
Run tests with "RUST_LOG=info "
$ RUST_LOG=info cargo test -p pallet-template it_
will run tests that starts with "it_"