debug_functions.php
Table of Contents
Functions
- check_debug_log_override() : void
- Check and set the debug log override status for the current user.
- create_debug_log_override() : void
- Create a debug log override for a specified user or globally.
- debug_function_call() : bool|void
- Debug called function and its arguments
- debug_stringify() : string
- Stringify variables for use in the debug log. This is used more as fallback to json_encode() failing to maintain quick readability of the logs.
Functions
check_debug_log_override()
Check and set the debug log override status for the current user.
check_debug_log_override() : void
This function determines if debug logging should be enabled based on system variables and the user's ID. If a debug override is set for a specific user or globally, and the override has not expired, debug logging will be activated. Expired overrides are removed.
create_debug_log_override()
Create a debug log override for a specified user or globally.
create_debug_log_override([int $debug_user = -1 ][, int $debug_expires = 60 ]) : void
This function sets a debug override that enables debug logging for a specified user
or all users if $debug_user is -1. The override is set to expire after a specified
duration in seconds. Any existing override settings are removed before the new values
are inserted.
Parameters
- $debug_user : int = -1
-
The user ID for whom to enable debug logging (-1 for all users). Default is -1.
- $debug_expires : int = 60
-
The time in seconds until the debug override expires, starting from the current time. Default is 60 seconds.
debug_function_call()
Debug called function and its arguments
debug_function_call(string $name, array<string|int, mixed> $args) : bool|void
The best way to use this function is to call it on the first line of a function definition:
function some_test($required, $num, $optional_bool = false) { debug_function_call(FUNCTION, func_get_args());
echo "called some_test" . PHP_EOL;
return;
}
Parameters
- $name : string
-
The function name
- $args : array<string|int, mixed>
-
The "runtime" args
Return values
bool|void —@see debug()
debug_stringify()
Stringify variables for use in the debug log. This is used more as fallback to json_encode() failing to maintain quick readability of the logs.
debug_stringify(mixed $value) : string
Parameters
- $value : mixed
-
Any value that needs stringified