The debug_function_enter and debug_function_return functions may be used to selectively send debugging messages to stderr and / or the system event log indicating that a function has been entered or returned from. An indent value is also maintained, by incrementing on function enter and decrementing on function return, to aid visual parsing of the debugging output.
debug_function_enter
$1 - The name of the function. $2+ - The (optional) calling parameters, usually inserted using ${@} or similar, as shown in the example below.
debug_function_return
$1 - The (optional) return value.
$DEBUG - If this global variable is set then output will be sent to stderr.
$LOGGING - If this global variable is set then output will be sent to the system event log.
debug: function factorial 5 debug: { debug: function factorial 4 debug: { debug: function factorial 3 debug: { debug: function factorial 2 debug: { debug: function factorial 1 debug: { debug: function factorial 0 debug: { debug: calculated 1 debug: } debug: calculated 1 * factorial 0 = 1 debug: } debug: calculated 2 * factorial 1 = 2 debug: } debug: calculated 3 * factorial 2 = 6 debug: } debug: calculated 4 * factorial 3 = 24 debug: } debug: calculated 5 * factorial 4 = 120 debug: } The factorial of 5 is 120