tools-logs.html.twig 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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.log' %}
  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) %}
  19. {% set logs = logfile ? logviewer.objectTail(logfile, lines|int, false) : [] %}
  20. {% set log_files = admin.getLogFiles() %}
  21. {% set title = log_files[file] %}
  22. <div class="logs-output">
  23. <form id="logs-form">
  24. <div class="block block-select">
  25. <div class="form-field">
  26. <div class="form-data">
  27. {% set lines_list = {10:'10 entries', 25:'25 entries', 50:'50 entries', 100:'100 entries', 200:'200 entries', 500:'500 entries'} %}
  28. {{ macro.render_select('log', log_files, file) }}
  29. {{ macro.render_select('verbose', {'false':'Essential Output', 'true':'Verbose Output'}, verbose) }}
  30. {{ macro.render_select('lines', lines_list, lines) }}
  31. </div>
  32. </div>
  33. </div>
  34. </form>
  35. <h1>{{ title }} Output</h1>
  36. <h3>Display the {{ lines }} most recent entries...</h3>
  37. <table class="noflex">
  38. <thead>
  39. <tr>
  40. <th class="date">Date</th>
  41. <th class="level">Level</th>
  42. <th class="message">Message</th>
  43. </tr>
  44. </thead>
  45. <tbody>
  46. {% for log in logs %}
  47. <tr>
  48. <td class="date" title="{{ log.date|date('r') }}">{{ log.date|date }}</td>
  49. <td class="level"><span class="badge {{ log.level|lower }}">{{ log.level }}</span></td>
  50. <td class="message">{{ log.message }}</td>
  51. {% if verbose %}
  52. </tr>
  53. <tr class="trace">
  54. <td colspan="2">&nbsp;</td>
  55. <td>
  56. <div class="overflow">
  57. <ol>
  58. {% for tracerow in log.trace %}
  59. <li><code>{{ tracerow }}</code></li>
  60. {% endfor %}
  61. </ol>
  62. </div>
  63. </td>
  64. {% endif %}
  65. </tr>
  66. {% endfor %}
  67. </tbody>
  68. </table>
  69. </div>
  70. </div>