You could do something like this : template trace*(words: varargs[typed, `$`]) = echo getStackTrace() echo "=> ", words proc main() = trace "Hello, world !" Run
This will only work if you have the stacktrace in your build (see <https://nim-lang.org/docs/nimc.html#additional-features> for more info - otherwise -d:debug does the trick)