Yii2 Bootstrap 3
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.

72 lines
1.7 KiB

<?php
use yii\helpers\Html;
use yii\grid\GridView;
use yii\data\ArrayDataProvider;
use yii\log\Logger;
?>
<h1>Log Messages</h1>
<?php
echo GridView::widget([
'dataProvider' => $dataProvider,
'id' => 'log-panel-detailed-grid',
'filterModel' => $searchModel,
'filterUrl' => $panel->getUrl(),
11 years ago
'rowOptions' => function ($model, $key, $index, $grid) {
switch($model['level']) {
case Logger::LEVEL_ERROR : return ['class' => 'danger'];
case Logger::LEVEL_WARNING : return ['class' => 'warning'];
case Logger::LEVEL_INFO : return ['class' => 'success'];
default: return [];
}
},
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'time',
11 years ago
'value' => function ($data) {
$timeInSeconds = $data['time'] / 1000;
$millisecondsDiff = (int)(($timeInSeconds - (int)$timeInSeconds) * 1000);
return date('H:i:s.',$timeInSeconds) . sprintf('%03d',$millisecondsDiff);
},
'headerOptions' => [
'class' => 'sort-numerical'
]
],
[
'attribute' => 'level',
11 years ago
'value' => function ($data) {
return Logger::getLevelName($data['level']);
},
'filter' => [
Logger::LEVEL_TRACE => ' Trace ',
Logger::LEVEL_INFO => ' Info ',
Logger::LEVEL_WARNING => ' Warning ',
Logger::LEVEL_ERROR => ' Error ',
],
],
'category',
[
'attribute' => 'message',
11 years ago
'value' => function ($data) {
$message = nl2br(Html::encode($data['message']));
if (!empty($data['trace'])) {
$message .= Html::ul($data['trace'], [
'class' => 'trace',
11 years ago
'item' => function ($trace) {
return "<li>{$trace['file']} ({$trace['line']})</li>";
}
]);
};
return $message;
},
'format' => 'html',
'options' => [
'width' => '50%',
],
],
],
]);
?>