Debugging and Emitting Debug Events
The modules provide emit_debug_event
functions or dedicated DebugEvent
structures to help you trace what’s happening inside your code during development and testing.
How to Use Debug Events:
Insert calls to
emit_debug_event(key, value)
at critical points in your code—such as right before a trade price calculation or after updating a deny list.By reviewing emitted debug events in test outputs or the Sui CLI logs, you can pinpoint the exact stage at which unexpected behavior occurs.
Best Practices:
Strategic Placement: Only add debug events around complex logic (e.g., minting large batches, performing swaps in TRADE) to avoid cluttering your output.
Remove or Comment Out: Once your code is stable, remove or comment out extra debug events to keep production logs clean.
Example:
This line emits a DebugEvent
that you can see in test logs, helping you confirm that the liquidity addition flow is triggered correctly.
By running unit tests frequently, understanding common issues, and leveraging debug events for granular tracing, you can identify and resolve problems efficiently. This proactive approach to testing and troubleshooting ensures the integrity and stability of your Artinals-based NFT platform, enhancing user trust and maintaining a reliable marketplace experience.
Last updated