Source for file Debug.class.php
Documentation is available at Debug.class.php
* Gumbo Library Framework
* This library is being released under the terms of the New BSD License. A
* copy of the license is packaged with the software (LICENSE.txt). If no
* copy is found, a copy of the license template can be found at:
* http://www.opensource.org/licenses/bsd-license.php
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
gumbo_load ("Interface_Debug");
gumbo_load ("Debug_Message");
class Gumbo_Debug implements Gumbo_Interface_Debug, Gumbo_Interface_Singleton, IteratorAggregate {
/** @var Gumbo_Interface_Singleton $_instance */
private static $_instance =
null;
/** @var bool $_active if Debug mode is active */
/** @var array $_list list of Debug Messages */
/** @var num $_time start time of the program */
/** @var bool $_inclusive the list of elements are inclusive if true, exclusive if false */
/** @var array $_functions list of functions to allow/deny */
/** @var array $_classes list of classes to include */
/** @var array $_files list of files to include */
* Constructor, for Singleton Pattern
* Singleton Pattern Method
* @return Gumbo_Interface_Debug
if (self::$_instance ==
null) {
self::$_instance =
new Gumbo_Debug ();
* Creates a message and adds it to the Debugger
* @param string $mess message content
* @param string $file file name
* @param int $line line number
* @param string $func function/method name
* @param string $cls class name
public function add ($mess, $file, $line, $func=
null, $cls=
null) {
* Adds a function to the restriction list
* @precondition function_exists ($func) or method_exists ($cls, $func)
* @precondition !isRestrictedFunction ($func, $cls)
* @param string $func function name
* @param string $cls class name
* @throws Gumbo_Exception
if (!is_null ($cls)) { $func .=
"." .
$cls; }
$e->setFunction (__METHOD__
);
* Adds a class to the restriction list
* @precondition is_class ($cls)
* @precondition !isRestrictedClass ($cls)
* @param string $cls class name
* @throws Gumbo_Exception
$e->setFunction (__METHOD__
);
* Adds a file to the restriction list
* @precondition file_exists ($file)
* @precondition $start < $end
* @precondition !isRestrictedFile ($file, $start, $end)
* @param string $file file name
* @param int $start start line
* @param int $end end line
* @throws Gumbo_Exception
if ($start <
0) { $start =
0; }
if ($end <
0) { $end =
0; }
$this->_files [] =
array ("file"=>
$file, "start"=>
$start, "end"=>
$end);
$e->setFunction (__METHOD__
);
* Resets all the restrictions
* @postcondition $_functions, $_classes, $_files = array ()
* Resets the Debug messages
* @postcondition setTime ()
* @postcondition $_messages = array ()
public function reset () {
$this->_messages =
array ();
* @postcondition $_active = true
* Deactivates the Debugger
* @postcondition $_active = false
* Sets the time stamp when the debugger started
* @throws Gumbo_Exception
$e->setFunction (__METHOD__
);
* Set the mode to Inclusive
* @postcondition $_inclusive = true
* Sets the mode to Exclusive
* @postcondition $_inclusive = false
* Returns all the messages of the Debugger
* Returns the time stamp when the Debugger was started
* Returns a list of restricted functions
* Returns a list of restricted classes
* Returns a list of restricted files
* Returns if the Debug mode is active
* Returns if the restrictions are inclusive
* Returns if the function is restricted
* @param string $func function name
* @param string $cls class name
* @throws Gumbo_Exception
// loop through restricted functions
$e->setFunction (__METHOD__
);
* Returns if the class is restricted
* @param string $cls class name
* @throws Gumbo_Exception
// loop through restricted classes
$e->setFunction (__METHOD__
);
* Returns if the file is restricted
* @param string $file file name
* @param int $line line number
* @throws Gumbo_Exception
// loop through restricted files
if ($val ['file'] ==
$file) {
// check if restricting entire file
if ($val ['start'] ==
0 &&
$val ['end'] ==
0) {
// check for restriction of line number
if (!is_null ($line) &&
($val ['start'] <=
$line &&
$val ['end'] >=
$line)) {
// check for restrition of file in general
$e->setFunction (__METHOD__
);
* Returns an Iterator object