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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. [
  28. 'attribute' => 'time',
  29. 'value' => function ($data) {
  30. $timeInSeconds = $data['time'] / 1000;
  31. $millisecondsDiff = (int) (($timeInSeconds - (int) $timeInSeconds) * 1000);
  32. return date('H:i:s.', $timeInSeconds) . sprintf('%03d', $millisecondsDiff);
  33. },
  34. 'headerOptions' => [
  35. 'class' => 'sort-numerical'
  36. ]
  37. ],
  38. [
  39. 'attribute' => 'level',
  40. 'value' => function ($data) {
  41. return Logger::getLevelName($data['level']);
  42. },
  43. 'filter' => [
  44. Logger::LEVEL_TRACE => ' Trace ',
  45. Logger::LEVEL_INFO => ' Info ',
  46. Logger::LEVEL_WARNING => ' Warning ',
  47. Logger::LEVEL_ERROR => ' Error ',
  48. ],
  49. ],
  50. 'category',
  51. [
  52. 'attribute' => 'message',
  53. 'value' => function ($data) use ($panel) {
  54. $message = Html::encode(is_string($data['message']) ? $data['message'] : VarDumper::export($data['message']));
  55. if (!empty($data['trace'])) {
  56. $message .= Html::ul($data['trace'], [
  57. 'class' => 'trace',
  58. 'item' => function ($trace) use ($panel) {
  59. return '<li>' . $panel->getTraceLine($trace) . '</li>';
  60. }
  61. ]);
  62. };
  63. return $message;
  64. },
  65. 'format' => 'raw',
  66. 'options' => [
  67. 'width' => '50%',
  68. ],
  69. ],
  70. ],
  71. ]);