Open JoshOrndorff opened 5 years ago
Add println!
, then compile is annoying for just debugging. Using tests for similar purpose should be possible from my experience, but I'm not sure how hard or time-consuming in substrate development.
This isn't very actionable, and the recipes aren't even in the main devhub repo anymore.
FWIW the original code snippet is still basically correct except that it now comes from srml_support
instead of sr_io
.
@bkchr has observed learners asking for help with printing simple debugging lines, so this issue is still relevant. He suggested we teach them to use https://crates.parity.io/sp_runtime/fn.print.html I suggest we demonstrate this technique in the PoE tutorial.
The snippet I quoted above is still basically right, but we need to run the node with -lruntime=debug
to see the message.
You can also show sp_std::if_std! {}
and with this: https://github.com/paritytech/substrate/commit/cb9c1818f198b946b402652d173bbd76e8fbe7d0 people are always run the runtime in native (when possible)
In the older runtime recipes that I deleted in 1495d8616b40, There was a section called "Print a message" which showed how to output simple debugging logs. That is not in the new https://substrate.dev/recipes .
I recently saw @shawntabrizi recommend instead to
println!
sIs this a better approach?
Original
Sometimes we need to print debug messages while building applications. This recipe shows how to print messages for debugging your Substrate runtime code.
You need to include
runtime_io
crate from the Substrate core in order to use IO functions from within the runtime modules.When this function is executed, the message will appear on the terminal where the Substrate node is running. The following screenshot shows the printed message.