Source for file debug.php
Documentation is available at debug.php
* Zikula Application Framework
* @copyright Robert Gasch
* @link http://www.zikula.org
* @version $Id: debug.php 24342 2008-06-06 12:03:14Z markwest $
* @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
* @author Robert Gasch rgasch@gmail.com
* log a string to the designated output destination
* @param file The file (passed from assertion handler)
* @param line The line (passed from assertion handler)
* @param assert_trigger The assert trigger (passed from assertion handler)
//pn_exit ('assertion failed', $file, $line, $assert_trigger);
return pn_exit ('assertion failed');
* Exit the program after displaying the appropriate messages
* @param msg The messgage to show
* @param html whether or not to generate HTML (can be turned off for command line execution)
function pn_exit ($msg, $html= true)
if (defined('_PNINSTALLVER') && $PNConfig['System']['development']) {
print ("Install Error:" . $msg . '<br />');
//Loader::loadClass('LogUtil');
$msg = "Exit-Handler: $msg\nStacktrace:\n";
if ($PNConfig['System']['development'])
* Serialize the given data in an easily human-readable way for debug purposes
* Taken from http://dev.nexen.net/scripts/details.php?scripts=707
* @param data The object to serialize
* @param functions whether to show function names for objects (default=false) (optional)
* @return string A string containing serialized data
function _prayer ($data, $functions= false, $recursionLevel= 0)
if ($recursionLevel > 5) {
return 'Max recursion level reached.';
if (defined('_PNINSTALLVER') && !$PNConfig['System']['development']) {
foreach ($data as $key => $value) {
$text .= sprintf ("<li>(%s) <strong>%s</strong>:\n", $type, $key);
$text .= _prayer ($value, $sf, $recursionLevel+ 1);
} elseif (eregi ('function', $type)) {
$text .= sprintf ("<li>(%s) <strong>%s</strong> </li>\n", $type, $key, $value);
/* There doesn't seem to be anything traversable inside functions. */
// You cannot do dataUtil::formatForDisplay on an object, so just display object type
if ($datatype == 'array') {
$text .= sprintf ("<li>(%s) <strong>%s</strong> = %s</li>\n", $type, $key, dataUtil::formatForDisplay($value));
elseif ($datatype == 'object') {
$text .= sprintf ("<li>(%s) <strong>%s</strong> -> %s</li>\n", $type, $key, dataUtil::formatForDisplay($value));
* Serialize the given data in an easily human-readable way for debug purposes
* Taken from http://dev.nexen.net/scripts/details.php?scripts=707
* @param data The object to serialize
* @param functions whether to show function names for objects (default=false) (optional)
* @return nothing, the data is directly printed
function prayer ($data, $functions= false)
if (defined('_PNINSTALLVER') && !$PNConfig['System']['development']) {
$text = '<div style="text-align:left">';
$text .= _prayer ($data, $functions);
* Simple timer class to measure code execution times.
* You can take multiple snapshots by calling the snap() function.
* For multiple measurements with 1 Timer, some basic statistics
* @param name The name of the timer
function Timer ($name= '')
* @param name The name of the timer
function reset ($name= '')
* return the current microtime
function stop ($insertNewRecord= true)
* print the timer results for a single measurement
$start = $this->times[0];
* print the timer results for multiple measurement
$start = $this->times[0];
for ($i= 1; $i< $size; $i++ )
$last = $this->times[$i- 1];
$stop = $this->times[$i];
$start = $this->times[0];
$stop = $this->times[$size- 1];
//$stats = sprintf ("(%d runs, min=%f, max=%f, avg=%f)\n", $size, $min, $max, $avg);
//print ("PNTimer: $diff $stats $this->name\n");
* take a snapshot while continuing the timing run
function snap ($doStats= false)
|