How to log in substrate pallets and how to see logs when running node (can be useful to see existing logs in polkadot when debugging).
Import log crate in Cargo.toml of pallets/template
[dependencies]log="0.4"
Add some logging to extrinsicdo_something
in pallet-template (gibberish in my case)
log::trace!(target:"lalala","do_something is working!");log::trace!(target:"ononono","do_something is working!");log::trace!(target:"test::werr","do_something is working!");...log::trace!(target:"lalala","do_something is done!");log::trace!(target:"ononono","do_something is done!");log::trace!(target:"test::werr","do_something is done!");
Build node, and run with log filtering (filters onlytarget: "lalala"
trace logs):
./target/release/node-template--dev--tmp--loglalala=trace
when execute extrinsics, trace log is in output:
different filtering (notice thattarget: "test::werr"
can be filtered like thattest=trace
)
./target/release/node-template--dev--tmp--loglalala=traceononono=tracetest=trace
--different output
For example to trace xcm messages in parachains/relay chain filter can be used:--log xcm=trace
Top comments(0)
For further actions, you may consider blocking this person and/orreporting abuse