AJAX
[ class tree: AJAX ] [ index: AJAX ] [ all elements ]

Source for file Debug.php

Documentation is available at Debug.php

  1. <?php
  2. define ("HTML_AJAX_NEWLINE""\n");
  3. // {{{ class HTML_AJAX_Debug
  4. /**
  5.  * AJAX Debugging implementation
  6.  *
  7.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  8.  * that is available through the world-wide-web at the following URI:
  9.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  10.  * the PHP License and are unable to obtain it through the web, please
  11.  * send a note to license@php.net so we can mail you a copy immediately.
  12.  *
  13.  * @category   HTML
  14.  * @package    AJAX
  15.  * @author     David Coallier <davidc@php.net>
  16.  * @copyright  2005 David Coallier
  17.  * @license    http://www.opensource.org/licenses/lgpl-license.php  LGPL
  18.  * @version    Release: @package_version@
  19.  */
  20. class HTML_AJAX_Debug {
  21.     // {{{ properties
  22.     
  23.     /**
  24.      * This is the error message.
  25.      *
  26.      * @access private
  27.      */
  28.     var $errorMsg;
  29.  
  30.     /**
  31.      * The line where the error occured.
  32.      *
  33.      * @access private
  34.      */
  35.     var $errorLine;
  36.  
  37.     /**
  38.      * The error code.
  39.      *
  40.      * @access private
  41.      */
  42.     var $errorCode;
  43.     
  44.     /**
  45.      * The file where the error occured.
  46.      *
  47.      * @access private
  48.      */
  49.     var $errorFile;
  50.  
  51.     /**
  52.      * Time the error occured
  53.      *
  54.      * @access private
  55.      */
  56.     var $_timeOccured;
  57.  
  58.     /**
  59.      * The whole error itself
  60.      *
  61.      * @access private
  62.      * @see errorMsg
  63.      * @see errorLine
  64.      * @see errorFile
  65.      * @see errorCode
  66.      */
  67.     var $error;
  68.  
  69.     /**
  70.      * The file to save the error to.
  71.      *
  72.      * @access private
  73.      * @default ajaxErrLog.xml
  74.      */
  75.     var $file 'ajaxErrLog.xml';
  76.     // }}}
  77.     // {{{ constructor
  78.     
  79.     /**
  80.      * The constructor.
  81.      *
  82.      * @param string $errorMsg   The error message.
  83.      * @param string $errLine    The line where error occured.
  84.      * @param string $errCode    The error Code.
  85.      * @param string $errFile    The file where error occured.
  86.      */
  87.     function HTML_AJAX_Debug($errMsg$errLine$errCode$errFile)
  88.     {
  89.         $this->errorMsg    $errMsg;
  90.         $this->errorLine   $errLine;
  91.         $this->errorCode   $errCode;
  92.         $this->errorFile   $errFile;
  93.         $this->_timeOccured date("Y-m-d H:i:s"time());
  94.         $this->xmlError();
  95.     }
  96.     // }}}
  97.     // {{{ xmlError
  98.     
  99.     /**
  100.      * This functions formats the error to xml format then we can save it.
  101.      *
  102.      * @access protected
  103.      * @return $this->error   the main error.
  104.      */
  105.     function xmlError()
  106.     {
  107.         $error  = " <when>{$this->_timeOccured}</when>" . HTML_AJAX_NEWLINE;
  108.         $error .= " <msg>{$this->errorMsg}</msg>"       . HTML_AJAX_NEWLINE;
  109.         $error .= " <code>{$this->errorCode}</code>"    . HTML_AJAX_NEWLINE;
  110.         $error .= " <line>{$this->errorLine}</line>"    . HTML_AJAX_NEWLINE;
  111.         $error .= " <file>{$this->errorFile}</file>"    . HTML_AJAX_NEWLINE . HTML_AJAX_NEWLINE;
  112.         return $this->error $error
  113.     }
  114.     // }}}
  115.     // {{{ sessionError
  116.     /**
  117.      * This function pushes the array $_SESSION['html_ajax_debug']['time'][]
  118.      * with the values inside of $this->error
  119.      *
  120.      * @access public
  121.      */
  122.     function sessionError() 
  123.     {
  124.         $_SESSION['html_ajax_debug']['time'][] = $this->error;
  125.     }
  126.     // }}}
  127.     // {{{ _saveError
  128.     /**
  129.      * This function saves the error to a file
  130.      * appending to this file.
  131.      *
  132.      * @access private.
  133.      */
  134.     function _saveError()
  135.     {
  136.         if ($handle = fopen($this->file'a')) {
  137.             fwrite($handle, $this->error);
  138.         }
  139.     }
  140.     // }}}
  141. }
  142. // }}}

Documentation generated on Sat, 05 May 2007 18:00:12 -0400 by phpDocumentor 1.3.0. PEAR Logo Copyright © PHP Group 2004.