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

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