Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

76 linhas
2.5KB

  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. ]);