コード例 #1
0
ファイル: Console.php プロジェクト: xamiro-dev/xamiro
 /**
  * log to console directly with this method passing only the first required parameter and to change
  * the log type the third parameter according to allowed log types. pass a lable for second parameter
  * to describe the message send to console.
  *
  * @error 10908
  * @param null|mixed $mixed expects the message of any type to send to console
  * @param null|string $label expects the optional label to describe the first parameter
  * @param string $type expects the log type - see log type array
  * @param array $options expects optional parameters
  * @return void
  * @throws Xapp_Error
  */
 public function log($mixed = null, $label = null, $type = 'info', array $options = array())
 {
     $type = strtolower((string) $type);
     if (array_key_exists($type, self::$_typeMap)) {
         if ($type === 'ini') {
             $this->ini($mixed, $label, $options);
         }
         if ($label !== null) {
             $label = trim(trim($label), ':') . ':';
         }
         switch ($this->_driver) {
             case 'chromephp':
                 switch ($type) {
                     case $type === 'ungroup' || $mixed === null:
                         $this->console->groupEnd();
                         break;
                     case 'group':
                         $this->console->group($mixed);
                         break;
                     case 'trace':
                         $this->console->log((string) $label, $mixed, 'info');
                         break;
                     default:
                         $this->console->log((string) $label, $mixed, self::$_typeMap[$type]);
                 }
                 break;
             case 'firephp':
                 switch ($type) {
                     case $type === 'ungroup' || $mixed === null:
                         $this->console->groupEnd();
                         break;
                     case 'group':
                         $this->console->group($mixed, $options);
                         break;
                     case 'trace':
                         $this->console->trace($label);
                         break;
                     default:
                         $this->console->{$type}($mixed, (string) $label, $options);
                 }
                 break;
         }
     } else {
         throw new Xapp_Error(xapp_sprintf(_("xapp console log type: %s not supported"), $type), 1090801);
     }
 }
コード例 #2
0
 /**
  * Shows profiles
  */
 protected function showProfiles()
 {
     // build html of all profilers
     // each profiler has its own sub category
     $profilerManager = $this->getProfilerManager();
     if ($profilerManager && count($profilerManager)) {
         $this->openCat("Profiles");
         foreach ($profilerManager as $profiler) {
             $totalTime = count($profiler) ? $profiler->getTotalElapsedSecs() : 0;
             $totalTime = number_format($totalTime, 4, ".", " ");
             $subTitle = $profiler->getProfilerName() . " (total execution time : {$totalTime} s)";
             $this->firePhp->group($subTitle, array("Collapsed" => true, "Color" => "magenta"));
             if (count($profiler)) {
                 foreach ($profiler as $i => $profile) {
                     $funcName = $profile->getCallingFunction();
                     $file = $profile->getCallingFile();
                     $line = $profile->getCallingLine();
                     $comment = $profile->getComment();
                     $this->firePhp->group("#{$i} {$funcName}", array("Collapsed" => false, "Color" => "green"));
                     $this->firePhp->log("Start file : {$file}");
                     $this->firePhp->log("Start line : {$line}");
                     if ($comment) {
                         $this->firePhp->log("Comment : {$comment}");
                     }
                     // parameters
                     if ($profile->getParams()) {
                         $this->firePhp->log($profile->getParams(), "Params");
                     }
                     // stack trace
                     $trace = array();
                     $trace[] = array("", "Function", "Line", "File");
                     $stackTrace = $profile->getCallingTrace();
                     $countTrace = count($stackTrace);
                     if ($stackTrace) {
                         foreach ($stackTrace as $k => $t) {
                             $trace[] = array($countTrace - 1 - $k, $t["func"], $t["line"], $t["file"]);
                         }
                     } else {
                         // empty stack trace
                         $table[] = array("* empty *");
                     }
                     $this->firePhp->table("Stack trace", $trace);
                     // query stats
                     $startTime = $profile->getStartMicrotime() - $_SERVER["REQUEST_TIME_FLOAT"];
                     $endTime = $profile->getEndMicrotime() ? $profile->getEndMicrotime() - $_SERVER["REQUEST_TIME_FLOAT"] : 0;
                     $startMemory = $profile->getStartMemoryUsage(true);
                     $endMemory = $profile->getEndMemoryUsage(true);
                     $startPeakMemory = $profile->getStartPeakMemoryUsage(true);
                     $endPeakMemory = $profile->getEndPeakMemoryUsage(true);
                     $this->firePhp->group("Measures", array("Collapsed" => true, "Color" => "orange"));
                     $this->firePhp->log("Started at : " . number_format($startTime, 4) . " s");
                     $this->firePhp->log("Ended at : " . number_format($endTime, 4) . " s");
                     $this->firePhp->log("Execution time : " . number_format($profile->getElapsedSecs(), 4) . " s");
                     $this->firePhp->log("Start memory usage : {$startMemory}");
                     $this->firePhp->log("End memory usage : {$endMemory}");
                     $this->firePhp->log("Start memory peak usage : {$startPeakMemory}");
                     $this->firePhp->log("End memory peak usage : {$endPeakMemory}");
                     $this->firePhp->groupEnd();
                     $this->firePhp->groupEnd();
                 }
             } else {
                 // no profile
                 $this->firePhp->log("No profile");
             }
             $this->firePhp->groupEnd();
         }
         $this->closeCat();
     }
 }
コード例 #3
0
ファイル: firephp.php プロジェクト: hkilter/OpenSupplyChains
 public function groupEnd()
 {
     parent::groupEnd();
     return $this;
 }