Source for file DebugHandler.class.php

Documentation is available at DebugHandler.class.php

  1. <?php
  2.  
  3. require_once(HARMONI."debugHandler/DebugItem.class.php");
  4. //require_once(HARMONI."debugHandler/DebugHandler.interface.php");
  5.  
  6. /**
  7. * @const integer DEBUG_API1 Debug level constant
  8. * @package harmoni.utilities.debugging
  9. ***/
  10. define("DEBUG_API1",6);
  11.  
  12. /**
  13. * @const integer DEBUG_API2 Debug level constant
  14. * @package harmoni.utilities.debugging
  15. ***/
  16. define("DEBUG_API2",7);
  17.  
  18. /**
  19. * @const integer DEBUG_API3 Debug level constant
  20. * @package harmoni.utilities.debugging
  21. ***/
  22. define("DEBUG_API3",8);
  23.  
  24. /**
  25. * @const integer DEBUG_API4 Debug level constant
  26. * @package harmoni.utilities.debugging
  27. ***/
  28. define("DEBUG_API4",9);
  29.  
  30. /**
  31. * @const integer DEBUG_API5 Debug level constant
  32. * @package harmoni.utilities.debugging
  33. ***/
  34. define("DEBUG_API5",10);
  35.  
  36. /**
  37. * @const integer DEBUG_USER1 Debug level constant
  38. * @package harmoni.utilities.debugging
  39. ***/
  40. define("DEBUG_USER1",1);
  41.  
  42. /**
  43. * @const integer DEBUG_USER2 Debug level constant
  44. * @package harmoni.utilities.debugging
  45. ***/
  46. define("DEBUG_USER2",2);
  47.  
  48. /**
  49. * @const integer DEBUG_USER3 Debug level constant
  50. * @package harmoni.utilities.debugging
  51. ***/
  52. define("DEBUG_USER3",3);
  53.  
  54. /**
  55. * @const integer DEBUG_USER4 Debug level constant
  56. * @package harmoni.utilities.debugging
  57. ***/
  58. define("DEBUG_USER4",4);
  59.  
  60. /**
  61. * @const integer DEBUG_USER5 Debug level constant
  62. * @package harmoni.utilities.debugging
  63. ***/
  64. define("DEBUG_USER5",5);
  65.  
  66. /**
  67. * @const integer DEBUG_SYS1 Debug level constant
  68. * @package harmoni.utilities.debugging
  69. ***/
  70. define("DEBUG_SYS1",11);
  71.  
  72. /**
  73. * @const integer DEBUG_SYS2 Debug level constant
  74. * @package harmoni.utilities.debugging
  75. ***/
  76. define("DEBUG_SYS2",12);
  77.  
  78. /**
  79. * @const integer DEBUG_SYS3 Debug level constant
  80. * @package harmoni.utilities.debugging
  81. ***/
  82. define("DEBUG_SYS3",13);
  83.  
  84. /**
  85. * @const integer DEBUG_SYS4 Debug level constant
  86. * @package harmoni.utilities.debugging
  87. ***/
  88. define("DEBUG_SYS4",14);
  89.  
  90. /**
  91. * @const integer DEBUG_SYS5 Debug level constant
  92. * @package harmoni.utilities.debugging
  93. ***/
  94. define("DEBUG_SYS5",15);
  95.  
  96. /**
  97. * The DebugHandler keeps track of multiple DebugItems.
  98. *
  99. * @package harmoni.utilities.debugging
  100. *
  101. * @copyright Copyright &copy; 2005, Middlebury College
  102. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  103. *
  104. * @version $Id: DebugHandler.class.php,v 1.10 2007/09/04 20:25:33 adamfranco Exp $
  105. ***/
  106.  
  107. class DebugHandler {
  108. /**
  109. * @var array $_queue The array of DebugItems.
  110. * @access private
  111. ***/
  112. var $_queue;
  113. /**
  114. * @access private
  115. * @var integer $_outputLevel The internal output level.
  116. ***/
  117. var $_outputLevel;
  118. /**
  119. * The constructor.
  120. * @access public
  121. * @return void
  122. ***/
  123. function DebugHandler() {
  124. $this->_queue = array();
  125. $this->_outputLevel = 0;
  126. }
  127. /**
  128. * Assign the configuration of this Manager. Valid configuration options are as
  129. * follows:
  130. * database_index integer
  131. * database_name string
  132. *
  133. * @param object Properties $configuration (original type: java.util.Properties)
  134. *
  135. * @throws object OsidException An exception with one of the following
  136. * messages defined in org.osid.OsidException: {@link }
  137. * org.osid.OsidException#OPERATION_FAILED OPERATION_FAILED},
  138. * {@link org.osid.OsidException#PERMISSION_DENIED}
  139. * PERMISSION_DENIED}, {@link }
  140. * org.osid.OsidException#CONFIGURATION_ERROR
  141. * CONFIGURATION_ERROR}, {@link }
  142. * org.osid.OsidException#UNIMPLEMENTED UNIMPLEMENTED}, {@link }
  143. * org.osid.OsidException#NULL_ARGUMENT NULL_ARGUMENT}
  144. *
  145. * @access public
  146. */
  147. function assignConfiguration ( $configuration ) {
  148. $this->_configuration =$configuration;
  149. }
  150.  
  151. /**
  152. * Return context of this OsidManager.
  153. *
  154. * @return object OsidContext
  155. *
  156. * @throws object OsidException
  157. *
  158. * @access public
  159. */
  160. function getOsidContext () {
  161. return $this->_osidContext;
  162. }
  163.  
  164. /**
  165. * Assign the context of this OsidManager.
  166. *
  167. * @param object OsidContext $context
  168. *
  169. * @throws object OsidException An exception with one of the following
  170. * messages defined in org.osid.OsidException: {@link }
  171. * org.osid.OsidException#NULL_ARGUMENT NULL_ARGUMENT}
  172. *
  173. * @access public
  174. */
  175. function assignOsidContext ( $context ) {
  176. $this->_osidContext =$context;
  177. }
  178. /**
  179. * Adds debug text to the handler.
  180. *
  181. * @param mixed $debug Either a string with debug text or a DebugItem object.
  182. * @param optional int $level The detail level of the debug text.
  183. * @param optional string $category The text category.
  184. * @access public
  185. * @return void
  186. ***/
  187. function add( $debug, $level=5, $category="general") {
  188. if (is_object($debug))
  189. $this->_add($debug, debug_backtrace());
  190. else if (is_string($debug)) {
  191. $this->_add( new DebugItem($debug, $level, $category), debug_backtrace());
  192. }
  193. else
  194. return "Exception";
  195. }
  196. /**
  197. * Adds a DebugItem to the queue.
  198. *
  199. * @param object DebugItem $debugItem The DebugItem to add to the queue.
  200. * @param optional array $debugBacktrace A DebugBacktrace array.
  201. * @access private
  202. * @return void
  203. ***/
  204. function _add( $debugItem, $debugBacktrace ) {
  205. $debugItem->setBacktrace($debugBacktrace);
  206.  
  207. $this->_queue[] = $debugItem;
  208. }
  209. /**
  210. * Returns the number of DebugItems registered.
  211. *
  212. * @access public
  213. * @return int The DebugItem count.
  214. ***/
  215. function getDebugItemCount() {
  216. return count($this->_queue);
  217. }
  218. /**
  219. * Returns an array of DebugItems, optionally limited to category $category.
  220. *
  221. * @param optional string $category The category.
  222. * @access public
  223. * @return array The array of DebugItems.
  224. ***/
  225. function getDebugItems( $category="" ) {
  226. $array = array();
  227. for ($i = 0; $i < $this->getDebugItemCount(); $i++) {
  228. if ($category == "" || $this->_queue[$i]->getCategory() == $category)
  229. $array[] = $this->_queue[$i];
  230. }
  231. return $array;
  232. }
  233.  
  234. /**
  235. * Sets the internal output level to $level. This can be overridden at output time.
  236. * @param integer $level
  237. * @access public
  238. * @return void
  239. ***/
  240. function setOutputLevel($level) {
  241. $this->_outputLevel = $level;
  242. }
  243. /**
  244. * Returns the internal output level.
  245. * @access public
  246. * @return integer
  247. ***/
  248. function getOutputLevel() {
  249. return $this->_outputLevel;
  250. }
  251. }
  252.  
  253. ?>

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