[line 60]
BS XRay - BS Language Component(*) Collection of debugging methods
*) BS Language Components are collection of function and/or classes that are not inherited by Bs_Object AND are not dependent on any other classes or libs that use Bs_Object (to avoid cyclic dependences).
For comfort some short hand function have been defined that use this class. XR_isOn(); XR_echo ($msg, $_line_='', $_func_='', $_file_=''); // Use instead of PHP's echo XR_echoPre ($msg, $_line_='', $_func_='', $_file_=''); // Use instead of PHP's echo XR_dump ($foo, $_line_='', $_func_='', $_file_=''); // Use instead of PHP's var_dump() of print_r()
The Problem (to solve): ----------------------- While a silple PHP echo or var_dump() are simple function to use to do some simple debugging, there is a major drawback: You CAN'T use them in a *life* system. All the useres would see the output too. So how can you output info, that is only intended for the developer?
The Solution: ------------- Set a flag if request comes for a defined (developer) IP. Trace- and Debbug- function output only if request come for that given IP.
Usage: ------ Per default all XR-function will react if the requst IP is 'localhost' To set the IP(s) call: Bs_XRay::activateOnIP($IPs);
Depending on the callers IP, the GLOBAL flag: $XR_isOn is set to TRUE or FALSE. For performance reasons it's allowed to use the flag directy OR call XR_isOn() (2ed option costs a little more CPU, I think). E.g. : if ($GLOBALS['XR_isOn']) { / * trace something * / } OR if (XR_isOn()) { / * trace something * / }
Define the IP (or IP's) that will activate XRay. That is set $XR_isOn to TRUE.
The param can be an IP-string eg: '12.122.232.2' or array of IP-strings IP's can have '*' as wildcard. Froms like '12.2.' have the same meaning as '12.2.*.*' NOTE: If XRay is on, then PHP error reporting is set to E_ALL too.