- Documentation
- Server functions
- addDebugHook
Function
addDebugHook
Attaches a function to events or function calls, for tracing and profiling. preEvent and postEvent work for events, preFunction and postFunction for the functions in a name list (the list is required then). A preEvent or preFunction function can return "skip" to block the event or the call.
Syntax
bool addDebugHook(string hookType, function callbackFunction [, table nameList])Arguments
hookTypestring"preEvent","postEvent","preFunction"or"postFunction".callbackFunctionfunction- Events:
function(resource, eventName, source, client, ...); functions:function(resource, functionName, file, line, ...). nameListtable, optional- Event or function names.
Returns
true on success.
Example
A log of every kickPlayer with the name of the resource that called it.
addDebugHook("preFunction", function(resource, name, file, line, player)
outputServerLog(("%s woła %s (%s:%s)"):format(resource and getResourceName(resource) or "?", name, tostring(file), tostring(line)))
end, { "kickPlayer" })