<?php

/* 
 * EXAMPLE FILE FOR PTCDEBUG CLASS
 */
session_start();
// start session for persistent debugging and code highlighter popup
declare (ticks=1);
// declare globally for the code coverage and function calls trace
$_GET['debug'] = true;
// turn on the debug
//$_GET[ 'debug_off' ] = true;    	// turn off debug
require_once '../PtcDebug.php';
// include the PtcDebug class
$options = array('url_key' => 'debug', 'url_pass' => 'true', 'die_on_error' => false, 'debug_console' => true);
PtcDebug::load($options);
// initialize the class
/* START CODE COVERAGE ANALYSIS TO CHECK WHICH LINES HAVE BEEN EXECUTED */
PtcDebug::startCoverage();
// set option['code_coverage'] to "full" to check the hole application
/* START TRACING FUNCTION CALLS */
PtcDebug::startTrace();
// set option['trace_functions'] to "full" to check the hole application
/* LOGGING A MESSAGE */
PtcDebug::bufferLog('just a message');
/* LOGGING A VARIABLE WITH A STATEMENT */
$var = 'just a string';
PtcDebug::bufferLog($var, 'testing a variable');
/* LOGGING AN ARRAY TO THE MESSAGE PANEL WITH A DIFFERENT CATEGORY */
$array = array('key' => 'value', 'key1' => 'value1');
PtcDebug::bufferLog($array, 'testing an array', 'new category');
예제 #2
0
 /**
  * Set debug at runtime
  */
 protected static function _setDebug()
 {
     $debug = Module::merge(ptc_path('root') . '/app/config/debug.php');
     if (file_exists(ptc_path('root') . '/app/config/debug_ajax.php')) {
         if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && ('xmlhttprequest' === strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) || 'ajax' === strtolower($_SERVER['HTTP_X_REQUESTED_WITH']))) {
             $debug_ajax = (require_once ptc_path('root') . '/app/config/debug_ajax.php');
             $debug = array_merge($debug, $debug_ajax);
         }
     }
     static::option('debug', $debug);
     require_once ptc_path('root') . '/vendor/phptoolcase/phptoolcase/PtcDebug.php';
     if (!is_null(ptc_array_get(static::$_config, 'debug.replace_error_handler', null))) {
         $die_on_error = ptc_array_get(static::$_config, 'debug.die_on_error') ? true : false;
         Debug::setErrorHandler($die_on_error);
         ptc_array_set(static::$_config, 'debug.replace_error_handler', false, true);
     }
     if (ptc_array_get(static::$_config, 'debug.start')) {
         $exclude = ptc_array_get(static::$_config, 'debug.exclude_categories');
         if (is_string($exclude) && array_key_exists($exclude, static::$_debugLevels)) {
             ptc_array_set(static::$_config, 'debug.exclude_categories', static::$_debugLevels[$exclude], true);
         }
         if (isset($_GET['debug_level'])) {
             ptc_array_set(static::$_config, 'debug.exclude_categories', static::$_debugLevels[$_GET['debug_level']], true);
         }
         Debug::load(static::$_config['debug']);
     }
 }