Debug Functions

As you write Functions, you will likely need to inspect the state of your execution to fix issues with code correctness or performance. Below are features you can use to do this.

Console logging

Functions supports emitting console logs during execution for debugging purposes. To do so, simply use the console.log command to emit logs. For example:

Copied!
1 2 3 4 5 6 7 @Function() public testConsoleLogging(n: Integer): Integer { for (let i = 0; i < n; i++) { console.log(`Iteration ${i}`); } return n; }

When you run this Function using the Functions helper in Authoring, console logs will be captured and displayed below, along with timestamps:

console-logging

Using console logs in this way can be useful for debugging correctness issues. You can also add console logs to identify performance bottlenecks in your code. See the guide for optimizing performance for more information on how to improve the performance of link traversal logic.