Source for file debug.class.php

Documentation is available at debug.class.php

  1. <?php
  2.  
  3. require_once HARMONI . "debugHandler/NewWindowDebugHandlerPrinter.class.php";
  4.  
  5. /**
  6. * The debug class is a static abstract class that holds wrapper functions for the DebugHandler service in Harmoni.
  7. *
  8. * @see DebugHandlerInterface
  9. *
  10. * @package harmoni.utilities.debugging
  11. *
  12. * @copyright Copyright &copy; 2005, Middlebury College
  13. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  14. *
  15. * @version $Id: debug.class.php,v 1.19 2007/09/04 20:25:33 adamfranco Exp $
  16. *
  17. * @static
  18. ***/
  19. class debug {
  20. /**
  21. * Sends $text to the DebugHandler with level $level and category $category.
  22. * @static
  23. * @access public
  24. * @return void
  25. ***/
  26. function output( $text, $level = 5, $category = "general") {
  27. if (!$level) return;
  28. if (!Services::serviceAvailable("Debug"))
  29. return;
  30. $debugHandler = Services::getService("Debug");
  31. $outputLevel = $debugHandler->getOutputLevel();
  32.  
  33. if ($level <= $outputLevel)
  34. $debugHandler->add($text,$level,$category);
  35. }
  36. /**
  37. * Sets the DebugHandler service's output level to $level. If not specified will
  38. * return the current output level.
  39. * @param optional integer $level
  40. * @static
  41. * @access public
  42. * @return integer The current debug output level.
  43. ***/
  44. function level($level=null) {
  45. if (!Services::serviceAvailable("Debug")) {
  46. throwError ( new Error("Debug::level($level) called but Debug service isn't available.","debug wrapper",false));
  47. return;
  48. }
  49. $debugHandler = Services::getService("Debug");
  50. if (is_int($level))
  51. $debugHandler->setOutputLevel($level);
  52. return $debugHandler->getOutputLevel();
  53. }
  54. /**
  55. * Prints current debug output using NewWindowDebugHandlerPrinter
  56. * @access public
  57. * @return void
  58. */
  59. function printAll($debugPrinter = null) {
  60. // ** parameter validation
  61. $extendsRule = ExtendsValidatorRule::getRule("DebugHandlerPrinterInterface");
  62. ArgumentValidator::validate($debugPrinter, OptionalRule::getRule($extendsRule), true);
  63. // ** end of parameter validation
  64. if (is_null($debugPrinter))
  65. NewWindowDebugHandlerPrinter::printDebugHandler(Services::getService("Debug"));
  66. else
  67. $debugPrinter->printDebugHandler(Services::getService("Debug"));
  68. }
  69. /**
  70. * Print the MySQL version of a query
  71. *
  72. * @param object Query $query
  73. * @return void
  74. * @access public
  75. * @since 3/2/05
  76. */
  77. function printQuery ($query) {
  78. print "\n<pre>";
  79. print_r(MySQL_SQLGenerator::generateSQLQuery($query));
  80. print "\n</pre>";
  81. }
  82. }
  83.  
  84. function printpre($array, $return=FALSE) {
  85. $string = "\n<pre>";
  86. $string .= print_r($array, TRUE);
  87. $string .= "\n</pre>";
  88. if ($return)
  89. return $string;
  90. else
  91. print $string;
  92. }
  93.  
  94. /**
  95. * Printpre an array or object, excluding any children named in the excludes list
  96. *
  97. * @param array $array
  98. * @param array $excludes
  99. * @return mixed void or string
  100. * @access public
  101. * @since 1/18/06
  102. */
  103. function printpreArrayExcept($array, $excludes = array(), $return=FALSE) {
  104. $string = "\n<pre>";
  105. foreach ($array as $key => $val) {
  106. if (!in_array($key, $excludes))
  107. $string .= "\n\n".$key."\n=> ".print_r($val, TRUE);
  108. }
  109. $string .= "\n</pre>";
  110. if ($return)
  111. return $string;
  112. else
  113. print $string;
  114. }
  115.  
  116.  
  117.  
  118. ?>

Documentation generated on Wed, 19 Sep 2007 10:22:39 -0400 by phpDocumentor 1.3.0RC3