Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
Showing with 72 additions and 0 deletions.
  1. +1 −0 README.markdown
  2. +63 −0 panels/YiiDebugToolbarPanelLogging.php
  3. +8 −0 views/panels/logging.php
View
1 README.markdown
@@ -79,5 +79,6 @@ See: [issues](https://github.com/malyshev/yii-debug-toolbar/issues)
<img src="https://dl.dropboxusercontent.com/u/6067542/yii-debug-toolbar/screenshot_1.png" alt="Screenshot1" />
<img src="https://dl.dropboxusercontent.com/u/6067542/yii-debug-toolbar/screenshot_2.png" alt="Screenshot2" />
<img src="https://dl.dropboxusercontent.com/u/6067542/yii-debug-toolbar/screenshot_3.png" alt="Screenshot3" />
+<img src="https://dl.dropboxusercontent.com/sh/09k0c42xasghu6c/Zq0WrQpxw5/screenshot_4.png" alt="Screenshot4" />
View
63 panels/YiiDebugToolbarPanelLogging.php
@@ -13,6 +13,7 @@
*
* @author Sergey Malyshev <malyshev.php@gmail.com>
* @author Igor Golovanov <igor.golovanov@gmail.com>
+ * @author Nabi KaramAliZadeh <info@nabi.ir>
* @version $Id$
* @package YiiDebugToolbar
* @since 1.1.7
@@ -34,6 +35,41 @@ class YiiDebugToolbarPanelLogging extends YiiDebugToolbarPanel
* @var array
*/
private $_logs;
+
+ /**
+ * Colors and max number of durations
+ * NOTE: all max numbers must be desc
+ * @author Nabi KaramAliZadeh <info@nabi.ir>
+ *
+ * @var array
+ */
+ public $colorsDuration = array(
+ array(
+ 'textColor'=>'#fff',
+ 'backgroundColor'=>'#c00',//red
+ 'maxNumber'=>1,
+ ),
+ array(
+ 'textColor'=>'#000',
+ 'backgroundColor'=>'#f60',//orange
+ 'maxNumber'=>0.1,
+ ),
+ array(
+ 'textColor'=>'#000',
+ 'backgroundColor'=>'#ff0',//yellow
+ 'maxNumber'=>0.01,
+ ),
+ array(
+ 'textColor'=>'#000',
+ 'backgroundColor'=>'#3c3',//green
+ 'maxNumber'=>0.001,
+ ),
+ array(
+ 'textColor'=>'#000',
+ 'backgroundColor'=>'#3cf',//blue
+ 'maxNumber'=>0.0001,
+ ),
+ );
/**
* {@inheritdoc}
@@ -114,4 +150,31 @@ protected function filterLogs()
}
return $logs;
}
+
+ /**
+ * Calculate duration execute between two trace
+ * @author Nabi KaramAliZadeh <info@nabi.ir>
+ *
+ * @param float $new
+ * @param float $old
+ * @return array
+ */
+ public function diffTime($new, $old)
+ {
+ $duration = $new - $old;
+ $duration = ($old===null) ? '-' : sprintf('%06f', $duration);
+ if($duration != '-'){
+ foreach($this->colorsDuration as $item){
+ if($duration >= $item['maxNumber']){
+ $return = $item;
+ break;
+ }
+ }
+ }else{
+ $return['textColor'] = '#000';
+ $return['backgroundColor'] = '#fff';
+ }
+ $return['duration'] = $duration;
+ return $return;
+ }
}
View
8 views/panels/logging.php
@@ -16,15 +16,23 @@
<th><?php echo YiiDebug::t('Level')?></th>
<th><?php echo YiiDebug::t('Category')?></th>
<th><?php echo YiiDebug::t('Time')?></th>
+ <th>Duration<br />
+ <?php foreach($this->colorsDuration as $item) :?>
+ <span style="background-color:<?php echo $item['backgroundColor']; ?>; width:9px; height:9px; display:block; float:left; margin:1px;"></span>
+ <?php endforeach; ?>
+ </th>
</tr>
</thead>
<tbody>
+ <?php $old=null; ?>
<?php foreach($logs as $id=>$entry): ?>
+ <?php $r=$this->diffTime($entry[3], $old); $old=$entry[3]; ?>
<tr>
<td data-ydtb-data-type="varchar"><?php echo nl2br($entry[0]) ?></td>
<td data-ydtb-data-type="char"><?php echo $entry[1]; ?></td>
<td data-ydtb-data-type="char"><?php echo $entry[2] ?></td>
<td data-ydtb-data-type="number"><?php echo date('H:i:s.',$entry[3]).sprintf('%06d',(int)(($entry[3]-(int)$entry[3])*1000000));?></td>
+ <td style="color:<?php echo $r['textColor']; ?>; background-color:<?php echo $r['backgroundColor']; ?>;"><?php echo $r['duration']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>

No commit comments for this range

Something went wrong with that request. Please try again.