log.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <!-- start log messages -->
  2. <table class="yiiLog" width="100%" cellpadding="2" style="border-spacing:1px;font:11px Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;color:#666666;">
  3. <tr>
  4. <th style="background:black;color:white;" colspan="5">
  5. Log aplikácie
  6. <?php
  7. $t = round(microtime(true) - YII_BEGIN_TIME, 3);
  8. $m = function_exists('memory_get_usage') ? '['.round(memory_get_usage()/1024/1024, 3).' MB]' : '';
  9. echo " * Stránka vygenerovaná za {$t} sek ~ ".round(1/$t)." strán/sek. ".$m;
  10. ?>
  11. </th>
  12. </tr>
  13. <tr style="background-color: #ccc;">
  14. <th style="width:120px">Čas</th>
  15. <th>Úroveň</th>
  16. <th>Kategória</th>
  17. <th>Zpráva</th>
  18. </tr>
  19. <?php
  20. $colors=array(
  21. CLogger::LEVEL_PROFILE=>'#DFFFE0',
  22. CLogger::LEVEL_INFO=>'#FFFFDF',
  23. CLogger::LEVEL_WARNING=>'#FFDFE5',
  24. CLogger::LEVEL_ERROR=>'#FFC0CB',
  25. );
  26. foreach($data as $index=>$log)
  27. {
  28. $color=($index%2)?'#F5F5F5':'#FFFFFF';
  29. if(isset($colors[$log[1]]))
  30. $color=$colors[$log[1]];
  31. $message='<pre>'.CHtml::encode(wordwrap($log[0])).'</pre>';
  32. $time=date('H:i:s.',$log[3]).(int)(($log[3]-(int)$log[3])*1000000);
  33. $time .= "<br />[+".round(($log[3]-YII_BEGIN_TIME)*1000, 0).'] ms';
  34. echo <<<EOD
  35. <tr style="background:{$color}">
  36. <td align="center">{$time}</td>
  37. <td>{$log[1]}</td>
  38. <td>{$log[2]}</td>
  39. <td>{$message}</td>
  40. </tr>
  41. EOD;
  42. }
  43. ?>
  44. </table>
  45. <!-- end of log messages -->