tools-logs.html.twig 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <div class="logs-content">
  2. {% macro render_select(name, options, selected, autokey=false) %}
  3. <div class="forms-select-wrapper">
  4. <select class="form-select" name="{{ name }}" data-grav-selectize>
  5. {% for key,option in options %}
  6. {% if autokey %}
  7. {% set key = key|of_type('int') ? option|lower : key %}
  8. {% endif %}
  9. <option value="{{ key }}" {{ key == selected ? ' selected' : '' }}>{{ option|titleize }}</option>
  10. {% endfor %}
  11. </select>
  12. </div>
  13. {% endmacro %}
  14. {% import _self as macro %}
  15. {% set file = grav.uri.query('log') ?: 'grav' %}
  16. {% set verbose = grav.uri.query('verbose') == 'true' ? true : false %}
  17. {% set lines = grav.uri.query('lines') ?: 20 %}
  18. {% set logfile = grav.locator.findResource("log://" ~ file ~ '.log') %}
  19. {% set logs = logviewer.objectTail(logfile, lines|int, false) %}
  20. <div class="logs-output">
  21. <form id="logs-form">
  22. <div class="block block-select">
  23. <div class="form-field">
  24. <div class="form-data">
  25. {% set log_files = config.plugins.admin.log_viewer_files|default(['grav','email']) %}
  26. {% set lines_list = {10:'10 entries', 25:'25 entries', 50:'50 entries', 100:'100 entries', 200:'200 entries', 500:'500 entries'} %}
  27. {{ macro.render_select('log', log_files, file, true) }}
  28. {{ macro.render_select('verbose', {'false':'Essential Output', 'true':'Verbose Output'}, verbose) }}
  29. {{ macro.render_select('lines', lines_list, lines) }}
  30. </div>
  31. </div>
  32. </div>
  33. </form>
  34. <h1>{{ file|titleize }} Log File</h1>
  35. <h3>Display the {{ lines }} most recent entries...</h3>
  36. <table class="noflex">
  37. <thead>
  38. <tr>
  39. <th class="date">Date</th>
  40. <th class="level">Level</th>
  41. <th class="message">Message</th>
  42. </tr>
  43. </thead>
  44. <tbody>
  45. {% for log in logs %}
  46. <tr>
  47. <td class="date">{{ log.date|date }}</td>
  48. <td class="level"><span class="badge {{ log.level|lower }}">{{ log.level }}</span></td>
  49. <td class="message">{{ log.message }}</td>
  50. {% if verbose %}
  51. </tr>
  52. <tr class="trace">
  53. <td colspan="2">&nbsp;</td>
  54. <td>
  55. <div class="overflow">
  56. <ol>
  57. {% for tracerow in log.trace %}
  58. <li><code>{{ tracerow }}</code></li>
  59. {% endfor %}
  60. </ol>
  61. </div>
  62. </td>
  63. {% endif %}
  64. </tr>
  65. {% endfor %}
  66. </tbody>
  67. </table>
  68. </div>
  69. </div>