Repository navigation
Easier Clarity debugging with logs #1910
hugoclrd
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Among many debugging methods, logging is a popular one.
It can help developers determine that a particular code path has been reached or view the value of a variable.
Clarity doesn't have real logging capabilities. The
printmethod allows developers to emit custom events. However, if the transaction fails, all events, including prints, are rolled back, which is unfortunate because that's when we need them the most.View all
printlogs in unit testsWith Clarinet SDK 3.3.0, all print events are logged in the console, even if the transaction fails.
In the screenshot below, you can see the two logs in the console:
"call increment"andu0.Note that it also includes the contract name and the line number where
printwas called.Configuring Vitest
Sometimes, the logs can be too noisy. With Vitest, it's possible to display the logs only if the test fails. Edit your
vitest.config.jsfile with the following:Or as an option in the command line:
Try it out
Make sure to use the clarinet-sdk v3.3.0 and run your unit tests to see the logs. We hope it will make debugging easier.
All reactions