debug

Simple debugging aids.
debug( s, [args] )
Debug.settings( [settings], [regexFilter] ) static
Debug.privateSettings( component, [regexFilter] ) static
Debug.printScopeChain( scope, [regexFilter] ) static
Before and After Functions
beforeFunction( args, callee, calleeThis, functionName )
afterFunction( returnValue, args, callee, calleeThis, functionName )
Modifying Arguments and Return Values
Debug.addBefore( [object], functionName, beforeFunction ) static
Debug.addAfter( [object], functionName, afterFunction ) static
Debug.removeAll( object, functionName ) static
Debug.TRACE_ENTRY static
Debug.TRACE_EXIT static
Debug.trace( [object], functionName ) static
Debug.traceAll( [object] ) static

Simple debugging aids.

debug( s, [args] )

This function is always defined, but behaves in one of three different ways. Normally, the function does nothing. If the script debugger is enabled, then it will print a formatted message to the application log. If this library has been imported, then the message will be printed to both the application log and the script console.

Debug.settings( [settings], [regexFilter] ) static

Print a list of the current global settings by key and value. An optional Regular Expression allows you to filter the results by printing only those keys that match the expression. If no settings instance is provided, the global shared settings will be used. (A regular expression can still be provided as the first argument.)

settings an optional
regexFilter an optional regular expression that printed keys must match

Debug.privateSettings( component, [regexFilter] ) static

Print a list of the private settings attached to a game component. An optional Regular Expression allows you to filter the results by printing only those keys that match the expression.

component a game component to print the private settings of
regexFilter an optional regular expression that printed keys must match

Debug.printScopeChain( scope, [regexFilter] ) static

Print a list of variables and their values in the chain of scopes starting with the parent of the scope provided. To create an appropriate scope for the current point in a function, use an empty function, e.g.:
 Debug.printScopeChain( function(){} );

The optional regexFilter will filter out non-matching variable names from the list.

Before and After Functions

Before and after functions are functions that can be wrapped around an existing function and will be called before or after the function that they wrap. Debug supports adding before and/or after functions on both global functions and member functions (this.f = function f() {}). To write a before or after function, define a function with the appropriate signature:

beforeFunction( args, callee, calleeThis, functionName )

args the arguments passed to the function
callee the wrapped function, which will be called when this function returns
calleeThis the this object for the wrapped function
functionName the name of the member function

returns the arguments to be passed to the callee when it is called

afterFunction( returnValue, args, callee, calleeThis, functionName )

returnValue the return value from the wrapped function (which was just called)
args the arguments passed to the function
callee the wrapped function
calleeThis the this object for the wrapped function
functionName the name of the member function

returns the return value for the member function call

Modifying Arguments and Return Values

A before or after function can change the apparent arguments to the function (before) or the apparent return value from the function (after). An before function is passed a copy of the original arguments and it returns the actual arguments to be passed to the wrapped function (which can simply be args if you do not wish to modify them). An after function is passed the return value from the wrapped function and it returns the apparent return value that will be returned to the caller (which can simply be returnValue if you do not wish to modify it).

Debug.addBefore( [object], functionName, beforeFunction ) static

Add a before function to a member function, which will be called just before the affected function whenever that function is called.

object the object that contains the function (default is the global object)
functionName the name of the member function
beforeFunction the function to be called before the affected function

Debug.addAfter( [object], functionName, afterFunction ) static

Add an after function to a member function, which will be called just after the affected function whenever that function is called.

object the object that contains the function (default is the global object)
functionName the name of the member function
afterFunction the function to be called after the affected function

Debug.removeAll( object, functionName ) static

Remove all before and after functions that have been added to a member function.

object the object that contains the function (default is the global object)
functionName the name of the member function

Debug.TRACE_ENTRY static

A function that can be used with Debug.beforeMember() to print tracing information whenever a function is called.

Debug.TRACE_EXIT static

A function that can be used with Debug.afterMember() to print tracing information whenever a function returns.

Debug.trace( [object], functionName ) static

This is a convenience that adds the TRACE_ENTRY and TRACE_EXIT before and after functions to a member function.

object the object that contains the member function (default is the global object)
functionName the name of the member function

Debug.traceAll( [object] ) static

Adds tracing to every function in an object.
object the object to trace (default is the global object)

Contents