#How do I log `Address` in a contract in local testing mode?
14 messages · Page 1 of 1 (latest)
do you run this as wasm or as compiled-in contract?
compiled-in contract (isn't this what "local-testing mode" means?)
depends on register_contract vs register_contract_wasm
register_contract
ah, I think you need the debug format {:?}
not sure why it's done exactly this way, but SDK mostly implements debug formatting for the data structures (and not Display that is used for {})
what is the exact syntax? If I just replace {} with {:?} I get address is :?
yeah, it seems like it's not used for the logging inside contracts...
sorry for the confusion, I haven't really looked much into this. basically we have debug formatting for the SDK types, but apparently it's only usable outside the contracts (like println!("{:?}", address); would output a strkey). I suppose outputting it that way from contract via host would require some trickery to only enable that when the contract is used in compiled mode (not sure if that's feasible)
a hacky-ish way to do debug outputs from the contracts would be to disable #[no_std] temporarily and just use println/eprintln with debug formatting
(you can make it less hacky by enabling #[no_std] conditionally for wasm target)
yeah this all seems pretty hackish. Am I doing something idiosyncratic by debugging using log messages in local testing mode?
you should be able to use the regular debugger