You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

detail.php 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /* @var $panel yii\debug\panels\LogPanel */
  3. /* @var $searchModel yii\debug\models\search\Log */
  4. /* @var $dataProvider yii\data\ArrayDataProvider */
  5. use yii\helpers\Html;
  6. use yii\grid\GridView;
  7. use yii\helpers\VarDumper;
  8. use yii\log\Logger;
  9. ?>
  10. <h1>Log Messages</h1>
  11. <?php
  12. echo GridView::widget([
  13. 'dataProvider' => $dataProvider,
  14. 'id' => 'log-panel-detailed-grid',
  15. 'options' => ['class' => 'detail-grid-view table-responsive'],
  16. 'filterModel' => $searchModel,
  17. 'filterUrl' => $panel->getUrl(),
  18. 'rowOptions' => function ($model, $key, $index, $grid) {
  19. switch ($model['level']) {
  20. case Logger::LEVEL_ERROR : return ['class' => 'danger'];
  21. case Logger::LEVEL_WARNING : return ['class' => 'warning'];
  22. case Logger::LEVEL_INFO : return ['class' => 'success'];
  23. default: return [];
  24. }
  25. },
  26. 'columns' => [
  27. ['class' => 'yii\grid\SerialColumn'],
  28. [
  29. 'attribute' => 'time',
  30. 'value' => function ($data) {
  31. $timeInSeconds = $data['time'] / 1000;
  32. $millisecondsDiff = (int) (($timeInSeconds - (int) $timeInSeconds) * 1000);
  33. return date('H:i:s.', $timeInSeconds) . sprintf('%03d', $millisecondsDiff);
  34. },
  35. 'headerOptions' => [
  36. 'class' => 'sort-numerical'
  37. ]
  38. ],
  39. [
  40. 'attribute' => 'level',
  41. 'value' => function ($data) {
  42. return Logger::getLevelName($data['level']);
  43. },
  44. 'filter' => [
  45. Logger::LEVEL_TRACE => ' Trace ',
  46. Logger::LEVEL_INFO => ' Info ',
  47. Logger::LEVEL_WARNING => ' Warning ',
  48. Logger::LEVEL_ERROR => ' Error ',
  49. ],
  50. ],
  51. 'category',
  52. [
  53. 'attribute' => 'message',
  54. 'value' => function ($data) {
  55. $message = Html::encode(is_string($data['message']) ? $data['message'] : VarDumper::export($data['message']));
  56. if (!empty($data['trace'])) {
  57. $message .= Html::ul($data['trace'], [
  58. 'class' => 'trace',
  59. 'item' => function ($trace) {
  60. return "<li>{$trace['file']} ({$trace['line']})</li>";
  61. }
  62. ]);
  63. };
  64. return $message;
  65. },
  66. 'format' => 'html',
  67. 'options' => [
  68. 'width' => '50%',
  69. ],
  70. ],
  71. ],
  72. ]);