motoko-base
motoko-base copied to clipboard
Document `debug` blocks, and how to use them.
Document how to use debug
blocks.
Debug blocks
A debug
block denotes code is only present in development mode, and elided in production.
debug { printfs here }
Compilation modes
from moc --help
:
-
--release
ignore debug expressions in source -
--debug
respect debug expressions in source (the default)
🎉
@matthewhammer
There is a quick reference on how I have used it: https://github.com/internet-computer/debug-block.mo
(As far as I know) there is no direct support in DFX to pass arguments to moc
(e.g. --debug
or --release
).
I think you can have a motoko
build method in dfx.json
and have an attribute "args"
with "--debug"
below it. @di-wu
Thanks @ggreif~ This makes it much simpler to set up!
dfx.json
{
"canisters": {
"prod": {
"type": "motoko",
"main": "src/main.mo",
"args": "--release"
},
"dev": {
"type": "motoko",
"main": "src/main.mo"
}
}
}