How to log inside runtime chain extension impl?
impl ChainExtension<Runtime> for CustomChainExtension {
fn call<E: Ext>(
func_id: u32,
env: Environment<E, InitState>,
) -> Result<RetVal, DispatchError>
where
<E::T as SysConfig>::AccountId: UncheckedFrom<<E::T as SysConfig>::Hash> + AsRef<[u8]>,
<E as Ext>::T: orml_tokens::Config,
{
match func_id {
0 => {
// deposit
let mut env = env.buf_in_buf_out();
let input_data = env.read(56)?;
log::debug!("hello ~~ deposit ~~");
I try to log hello ~~ but it doesn't show up in the console. What should I config to log inside chain extension runtime?
I also tried RUST_LOG=debug RUST_BACKTRACE=1 ./target/release/polkadex-node --dev --tmp -lruntime=debug but it doesn't work
@cmichi Could you take a quick look here, please? Thanks
@frankli-dev You can use e.g.
info!(
target: "runtime",
"[ChainExtension]|call|func_id:{:}", func_id
);
inside your runtime. If you then run the node via substrate-contracts-node --tmp --dev it will show up on the console.
I think in your code above the issue is that you use -lruntime=debug, but don't use log::debug!(target: "runtime", …);.
@cmichi it doesn't still work for me. I'm running on my own node which has custom chain extension implementation on the runtime
@frankli-dev Have you tried starting without the -l? Maybe try panic-king in your custom chain extension in the runtime, just to verify that the function is even hit?
@frankli-dev Have you tried starting without the
-l? Maybe try panic-king in your custom chain extension in the runtime, just to verify that the function is even hit?
yes. I tried to panic in the entry and it panics there. So the function is called. you mean runtime=debug?