Debug

Debug Functionality

Overview

The NCC API allows you to write debug to the slee_acs log in a similar way to normal debug output.

For example:

         Engine    AcsEngineSleeCallContext::getNodeCallContext():Returning 1a90910 node call context for fast key 'N2LN'
SDKn2MacroNodes    ----------------------------------------------------------------------------
SDKn2MacroNodes    N-Squared Logic Node: State 1 - processLogicNodeProcessLua ()
SDKn2MacroNodes    ----------------------------------------------------------------------------
SDKn2MacroNodes    Going to read from TEMPORARY->106
SDKn2MacroNodes    Read profile from block: 17
SDKn2MacroNodes    Read profile from tag: 106
        Chassis    void ncc::acs::doRetrieveProfileAction(acsChassisAction*, acsEngineContext_s*)
        Chassis     void ncc::acs::setupChassisAction(acsChassisAction*, int, int)
        Chassis    void ncc::acs::addRetrieveProfileTag(acsChassisAction*, profileBlockIdentifier, unsigned int)
SDKn2MacroNodes    N2 Logic Node State 2: moving to state 3 - processLogicNodeProfileRead
         Engine    macroNodeProcessor: Macro Node traversing to state 2

All debug is written with the debug flag ‘SDKn2MacroNodes’. This flag must either be enabled specifically in the SLEE debug settings, or not disabled when the ‘all’ debug setting is used. For example, either of these two debug settings will enable debug for the N2 Logic Node:

DEBUG=all,-COMMON_escher,-COMMON_escher_detail,-COMMON_FD,-COMMON_Utils,-Config
DEBUG=SDKn2MacroNodes

For efficiency, attempts to print debug when no debug flags are specified (i.e. the environment variable is unset) are ignored without further processing.


Functions


ncc.debug (target, indent)
  Parameters target The value(s) to be sent to the debug output (mandatory).
    indent Indentation to be applied to the debug output (optional, defaults to empty).
  Returns Nothing.
  Errors If the provided target is not a table and is unable to be turned into a string, the following error will be raised:

Unable to debug value of type <target type>.

Usage This function will dump the contents of target as debug within the NCC slee_acs output.

function foo (a)
	d = "foo (" .. a .. "): "
	local found = false
	ncc.debug ("Examining " .. a, d)
	-- excitingly complex logic left as an exercise for the reader
	ncc.debug ("All done, returning " .. found, d)
	return found
end

If target is a Lua table, it will be printed in an indented format for each value that is not nil; nil values are not stored in tables, because any undefined key in a Lua table implicitly equates to nil.

Note that debug table output may be used directly in Lua scripts for convenience.

foo = { ONE = 1, TWO = { THREE = "hello", FOUR = { FIVE = 5, SIX = 6, SEVEN = nil } } }
ncc.debug (foo)

The previous statements will produce:

SDKn2MacroNodes    {
SDKn2MacroNodes        ['ONE'] = 1,
SDKn2MacroNodes        ['TWO'] = {
SDKn2MacroNodes            ['FOUR'] = {
SDKn2MacroNodes                ['FIVE'] = 5,
SDKn2MacroNodes                ['SIX'] = 6
SDKn2MacroNodes            },
SDKn2MacroNodes            ['THREE'] = 'hello'
SDKn2MacroNodes        }
SDKn2MacroNodes    }

If target is not a table (i.e. a string literal, or an integer, or an empty string, etc., etc.), it will be turned into its string representation and and a single line of debug will be sent to the output.

ncc.debug ("The time is " .. os.date ())

The previous statement will produce:

SDKn2MacroNodes    The time is Thu Sep 18 17:00:00 2014

The indent parameter can be used to make certain debug stand out or be grouped together. If provided, it should be a string value that will be prefixed to every line of debug, so is not particularly useful unless outputting a table or when using a variable to group debug.

foo = { ONE = 1, TWO = { THREE = "hello", FOUR = { FIVE = 5, SIX = 6, SEVEN = nil } } }
ncc.debug (foo, "Example: ")

The previous statements will produce:

SDKn2MacroNodes    Example: {
SDKn2MacroNodes    Example:     ['ONE'] = 1,
SDKn2MacroNodes    Example:     ['TWO'] = {
SDKn2MacroNodes    Example:         ['FOUR'] = {
SDKn2MacroNodes    Example:             ['FIVE'] = 5,
SDKn2MacroNodes    Example:             ['SIX'] = 6
SDKn2MacroNodes    Example:         },
SDKn2MacroNodes    Example:         ['THREE'] = 'hello'
SDKn2MacroNodes    Example:     }
SDKn2MacroNodes    Example: }