The debug Console is the optimal way to debug script routines.
There are two Library Functions to send messages to the console.
Print('my text') - Sends a text message to the console, use this to send messages to the console indicating that portion of the code has executed.
PrintNumber(myvariable) - Sends the value of a variable to the console so you can verify a routine or calculation is behaving as expected at that point.
The above video with accompanying configuration demonstrates how to use the Debug Console.