Skip to content
Kavachकवच

Output: debug

● Beginner3 min

debug(value) prints a value with its file and line while you develop, and disappears from release builds.

fn main() {
    const total = 40 * 3
    debug(total)
    print("done")
}

The program ran and printed:

kavach run debug.kav

done
debug.kav: Kavach code, then what running it prints

Only done shows above, because debug writes to standard error, not standard output. In a terminal you see both: the debug line names the file and line it came from, so you know which debug printed it.

Why not just print?

debug needs no capability, so you can drop it into any function. And kavach build leaves it out completely, argument and all: a forgotten debug never reaches your users.

What Kavach does for you

  • debug() shows where, and never ships

    debug(x) prints the value with its file and line. Release builds leave it out, argument and all.

    spec 1.10