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

Source for file DebugLine.php

Documentation is available at DebugLine.php

  1. <?php
  2.  
  3. /**
  4.  * A loader class for the renderers.
  5.  *
  6.  * @package PHP_Debug
  7.  * @category PHP
  8.  * @author Loic Vernet <qrf_coil at yahoo dot fr>
  9.  * @since V2.0.0 - 10 Apr 2006
  10.  * 
  11.  * @package PHP_Debug
  12.  * @filesource
  13.  * @version    CVS: $Id: DebugLine.php,v 1.1 2008/05/02 14:26:37 c0il Exp $
  14.  */
  15.  
  16. {
  17.  
  18.     /**
  19.      * PHP_DEBUGLINE Types
  20.      *
  21.      * - TYPE_ANY          : All available types (for search mode)
  22.      * - TYPE_STD          : Standart debug
  23.      * - TYPE_QUERY        : Query debug
  24.      * - TYPE_REL          : Database related debug
  25.      * - TYPE_ENV          : Environment debug ($GLOBALS...)
  26.      * - TYPE_APPERROR     : Custom application error
  27.      * - TYPE_CREDITS      : Credits information
  28.      * - TYPE_SEARCH       : Search mode in debug
  29.      * - TYPE_DUMP         : Dump any kind of variable
  30.      * - TYPE_PROCESSPERF  : Performance analysys
  31.      * - TYPE_TEMPLATES    : Included templates of the calling script
  32.      * - TYPE_PAGEACTION   : Store main page action
  33.      * - TYPE_SQLPARSE     : SQL Parse error
  34.      * - TYPE_WATCH        : A variable to watch
  35.      * - TYPE_PHPERROR     : A debug generated by the custom error handler
  36.      *
  37.      * @category DebugLine
  38.      */
  39.     
  40.     const TYPE_ANY         = 0;
  41.     const TYPE_STD         = 1;
  42.     const TYPE_QUERY       = 2;
  43.     const TYPE_QUERYREL    = 3;
  44.     const TYPE_ENV         = 4;
  45.     const TYPE_APPERROR    = 5;
  46.     const TYPE_CREDITS     = 6;
  47.     const TYPE_SEARCH      = 7;
  48.     const TYPE_DUMP        = 8;
  49.     const TYPE_PROCESSPERF = 9;
  50.     const TYPE_TEMPLATES   = 10;
  51.     const TYPE_PAGEACTION  = 11;
  52.     const TYPE_SQLPARSE    = 12;
  53.     const TYPE_WATCH       = 13;
  54.     const TYPE_PHPERROR    = 14;
  55.     const TYPE_DEFAULT     = self::TYPE_STD;
  56.  
  57.     /**
  58.      * PHP_DEBUGLINE info levels
  59.      */
  60.     const INFO_LEVEL    = 1;
  61.     const WARNING_LEVEL = 2;
  62.     const ERROR_LEVEL   = 3;
  63.  
  64.    /** 
  65.     * Labels for debugline types
  66.     */
  67.     public static $debugLineLabels = array(
  68.         self::TYPE_ANY         => 'ALL'
  69.         self::TYPE_STD         => 'Standart',
  70.         self::TYPE_QUERY       => 'Query'
  71.         self::TYPE_QUERYREL    => 'Database related',
  72.         self::TYPE_ENV         => 'Environment',
  73.         self::TYPE_APPERROR    => 'Application error',
  74.         self::TYPE_CREDITS     => 'Credits',
  75.         self::TYPE_SEARCH      => 'Search',
  76.         self::TYPE_DUMP        => 'Variable dump',
  77.         self::TYPE_PROCESSPERF => 'Performance analysis',
  78.         self::TYPE_TEMPLATES   => 'Included files',
  79.         self::TYPE_PAGEACTION  => 'Page main action',
  80.         self::TYPE_SQLPARSE    => 'SQL parse error',
  81.         self::TYPE_WATCH       => 'Watch',
  82.         self::TYPE_PHPERROR    => 'PHP error'
  83.     );    
  84.         
  85.     /**
  86.      * Properties that stores the non formatted debug information
  87.      * 
  88.      * @since V2.0.0 - 11 apr 2006
  89.      * @var string 
  90.      */     
  91.     protected $info;
  92.     
  93.     /**
  94.      * Type of the debug information
  95.      * 
  96.      * @since V2.0.0 - 11 apr 2006
  97.      * @see Debug_Line constants
  98.      * @var integer 
  99.      */     
  100.     protected $type;
  101.  
  102.     /** 
  103.      * File of debug info
  104.      * 
  105.      * @since V2.0.0 - 11 apr 2006
  106.      * @var integer 
  107.      */
  108.     protected $file;
  109.  
  110.     /** 
  111.      * Line of debug info
  112.      * 
  113.      * @since V2.0.0 - 11 apr 2006
  114.      * @var integer 
  115.      */
  116.     protected $line;
  117.         
  118.     /** 
  119.      * Class from witch the debug was called
  120.      * 
  121.      * @since V2.0.0 - 13 apr 2006
  122.      * @var integer 
  123.      */
  124.     protected $class;
  125.  
  126.     /** 
  127.      * Function from wich the debug was called
  128.      * 
  129.      * @var integer 
  130.      * @since V2.0.0 - 11 apr 2006
  131.      */
  132.     protected $function;
  133.     
  134.     /** 
  135.      * Exection time for debug info
  136.      * 
  137.      * @var float 
  138.      * @see stopTimer()
  139.      * @since V2.0.0 - 16 apr 2006
  140.      */
  141.     protected $startTime;
  142.  
  143.     /** 
  144.      * Exection end time for debug info
  145.      * 
  146.      * @see PHP_Debug::stopTimer(), setEndTime()
  147.      * @since V2.0.0 - 16 apr 2006
  148.      * @var float 
  149.      */
  150.     protected $endTime;
  151.  
  152.     /**
  153.      * PHP_DebugLine class constructor
  154.      * 
  155.      * Here it is set :
  156.      * - the start time of the debug info
  157.      * - the traceback information
  158.      *
  159.      * @since V2.0.0 - 11 apr 2006
  160.      * @see PHP_Debug::add()
  161.      */
  162.     public function __construct($info$type = self::TYPE_DEFAULT)
  163.     {
  164.         $this->setStartTime();
  165.         $this->info = $info;
  166.         $this->type = $type;
  167.         $this->setTraceback();
  168.     }
  169.  
  170.     /**
  171.      * Fills properties of debug line with backtrace informations
  172.      * 
  173.      * @since V2.0.0 - 15 apr 2006
  174.      */
  175.     protected function setTraceback()
  176.     {
  177.         $callStack debug_backtrace();
  178.         $idx = 0;
  179.         
  180.         // Get max id of 'add' debug functions  
  181.         foreach($callStack as $lkey => $lvalue{
  182.             if (in_array($callStack[$lkey]['function']
  183.                     PHP_Debug::$excludedBackTraceFunctions== true
  184.             {
  185.                 $idx $lkey;
  186.             }
  187.         }
  188.  
  189.         $this->file     = !empty($callStack[$idx]  ['file'])     
  190.             ? $callStack[$idx]['file']       '';
  191.         $this->line     = !empty($callStack[$idx]  ['line'])     
  192.             ? $callStack[$idx]['line']       '';
  193.         $this->function = !empty($callStack[$idx+1]['function']
  194.             ? $callStack[$idx+1]['function''';
  195.         $this->class    = !empty($callStack[$idx+1]['class'])    
  196.             ? $callStack[$idx+1]['class']    '';
  197.     }
  198.  
  199.     /**
  200.      * Getter of all properties of Debug_Line object
  201.      * 
  202.      * @return array    Array containg all the properties of the debugline
  203.      * @since V2.0.0 - 21 apr 2006
  204.      */
  205.     public function getProperties()
  206.     {
  207.         return array(
  208.             'class'     => $this->class,
  209.             'file'      => $this->file,
  210.             'function'  => $this->function,
  211.             'line'      => $this->line,
  212.             'info'      => $this->info,
  213.             'type'      => $this->type,
  214.             'startTime' => $this->startTime,
  215.             'endTime'   => $this->endTime
  216.         );
  217.     }
  218.  
  219.     /**
  220.      * setter of endTime
  221.      * 
  222.      * @since V2.0.0 - 19 apr 2006
  223.      */
  224.     public function setEndTime($endTime '')
  225.     {
  226.         $this->endTime = $endTime $endTime : PHP_Debug::getMicroTimeNow();
  227.     }
  228.  
  229.     /**
  230.      * setter of startTime
  231.      * 
  232.      * @see pear bug http://pear.php.net/bugs/10919
  233.      * 
  234.      * @since V2.1.2 - 04 may 2006
  235.      */
  236.     public function setStartTime($startTime '')
  237.     {
  238.         $this->startTime = $startTime $startTime : PHP_Debug::getMicroTimeNow();
  239.     }
  240.  
  241.     /**
  242.      * Debug_Line default output function
  243.      * 
  244.      * @since V2.0.0 - 11 apr 2006
  245.      * @see PHP_Debug::dumpVar()
  246.      */
  247.     public function __toString()
  248.     {
  249.         return '<pre>'
  250.             PHP_Debug::dumpVar(
  251.                 $this
  252.                 __CLASS__
  253.                 false,
  254.                 PHP_DEBUG_DUMP_ARR_STR
  255.             )
  256.         . '</pre>';
  257.     }
  258.  
  259.     /**
  260.      * Function that give the debug type lable
  261.      * 
  262.      * @author COil
  263.      * @since  V2.0.0 - 2 apr 2007
  264.      */
  265.     public static function getDebugLabel($type)
  266.     {
  267.         return self::$debugLineLabels[$type];
  268.     }
  269. }

Documentation generated on Mon, 11 Mar 2019 15:28:39 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.