debug
Simple debugging aids.
Debug.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
When the debug library has been included in a script, the
function debug( s [,args...] )
will print formatted text to the console's error stream.
When the debug library has not been included in a script, debug(s)
does nothing.
In addition, this library defines an object, Debug which contains
useful debugging methods.
If the application is started in debug mode, this library will be
imported automatically. (This can be done by setting the debug
setting key or starting the application with the --debug
command line option.
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.
| regexFilter | an optional regular expression that printed keys must match |
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 |
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 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:
| 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
| 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
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).
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 |
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 |
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 |
A function that can be used with Debug.beforeMember() to print tracing
information whenever a function is called.
A function that can be used with Debug.afterMember() to print tracing
information whenever a function returns.
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 |
Adds tracing to every function in an object.
| object | the object to trace (default is the global object) |
Index Contents