logs.html.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <table class="logs" data-filter-level="Emergency,Alert,Critical,Error,Warning,Notice,Info,Debug" data-filters>
  2. <?php $channelIsDefined = isset($logs[0]['channel']); ?>
  3. <thead>
  4. <tr>
  5. <th data-filter="level">Level</th>
  6. <?php if ($channelIsDefined) { ?><th data-filter="channel">Channel</th><?php } ?>
  7. <th class="full-width">Message</th>
  8. </tr>
  9. </thead>
  10. <tbody>
  11. <?php
  12. foreach ($logs as $log) {
  13. if ($log['priority'] >= 400) {
  14. $status = 'error';
  15. } elseif ($log['priority'] >= 300) {
  16. $status = 'warning';
  17. } else {
  18. $severity = 0;
  19. if (($exception = $log['context']['exception'] ?? null) instanceof \ErrorException) {
  20. $severity = $exception->getSeverity();
  21. }
  22. $status = \E_DEPRECATED === $severity || \E_USER_DEPRECATED === $severity ? 'warning' : 'normal';
  23. } ?>
  24. <tr class="status-<?= $status; ?>" data-filter-level="<?= strtolower($this->escape($log['priorityName'])); ?>"<?php if ($channelIsDefined) { ?> data-filter-channel="<?= $this->escape($log['channel']); ?>"<?php } ?>>
  25. <td class="text-small" nowrap>
  26. <span class="colored text-bold"><?= $this->escape($log['priorityName']); ?></span>
  27. <span class="text-muted newline"><?= date('H:i:s', $log['timestamp']); ?></span>
  28. </td>
  29. <?php if ($channelIsDefined) { ?>
  30. <td class="text-small text-bold nowrap">
  31. <?= $this->escape($log['channel']); ?>
  32. </td>
  33. <?php } ?>
  34. <td>
  35. <?= $this->formatLogMessage($log['message'], $log['context']); ?>
  36. <?php if ($log['context']) { ?>
  37. <pre class="text-muted prewrap m-t-5"><?= $this->escape(json_encode($log['context'], \JSON_PRETTY_PRINT | \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES)); ?></pre>
  38. <?php } ?>
  39. </td>
  40. </tr>
  41. <?php
  42. } ?>
  43. </tbody>
  44. </table>