log.blade.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. @extends('admin.layouts.app')
  2. @section('title', '错误日志')
  3. @section('content')
  4. <div class="wrapper wrapper-content animated fadeInRight">
  5. <div class="row">
  6. <label for="" class="col-1"></label>
  7. <div class="col-8" style="padding: 0">
  8. <h1><i class="fa fa-calendar" aria-hidden="true"></i> Laravel Log Viewer</h1>
  9. <div class="list-group div-scroll">
  10. @foreach($folders as $folder)
  11. <div class="list-group-item">
  12. <a href="?f={{ \Illuminate\Support\Facades\Crypt::encrypt($folder) }}">
  13. <span class="fa fa-folder"></span> {{$folder}}
  14. </a>
  15. @if ($current_folder == $folder)
  16. <div class="list-group folder">
  17. @foreach($folder_files as $file)
  18. <a href="?l={{ \Illuminate\Support\Facades\Crypt::encrypt($file) }}&f={{ \Illuminate\Support\Facades\Crypt::encrypt($folder) }}"
  19. class="list-group-item @if ($current_file == $file) llv-active @endif">
  20. {{$file}}
  21. </a>
  22. @endforeach
  23. </div>
  24. @endif
  25. </div>
  26. @endforeach
  27. </div>
  28. </div>
  29. <div class="col-2" style="padding: 0">
  30. @foreach($files as $file)
  31. <a href="?l={{ \Illuminate\Support\Facades\Crypt::encrypt($file) }}"
  32. class="list-group-item @if ($current_file == $file) llv-active @endif">
  33. {{$file}}
  34. </a>
  35. @endforeach
  36. </div>
  37. </div>
  38. <div class="row">
  39. <label for="" class="col-1"></label>
  40. <div class="col-10 table-container">
  41. @if ($logs === null)
  42. <div>
  43. Log file >50M, please download it.
  44. </div>
  45. @else
  46. <table id="table-log" class="table table-striped"
  47. data-ordering-index="{{ $standardFormat ? 2 : 0 }}">
  48. <thead>
  49. <tr>
  50. @if ($standardFormat)
  51. <th>Level</th>
  52. <th>Context</th>
  53. <th>Date</th>
  54. @else
  55. <th>Line number</th>
  56. @endif
  57. <th>Content</th>
  58. </tr>
  59. </thead>
  60. <tbody>
  61. @foreach($logs as $key => $log)
  62. <tr data-display="stack{{{$key}}}">
  63. @if ($standardFormat)
  64. <td class="nowrap text-{{{$log['level_class']}}}">
  65. <span class="fa fa-{{{$log['level_img']}}}" aria-hidden="true"></span>&nbsp;&nbsp;{{$log['level']}}
  66. </td>
  67. <td class="text">{{$log['context']}}</td>
  68. @endif
  69. <td class="date">{{{$log['date']}}}</td>
  70. <td class="text">
  71. @if ($log['stack'])
  72. <button type="button"
  73. class="float-right expand btn btn-outline-dark btn-sm mb-2 ml-2"
  74. data-display="stack{{{$key}}}">
  75. <span class="fa fa-search"></span>
  76. </button>
  77. @endif
  78. {{{$log['text']}}}
  79. @if (isset($log['in_file']))
  80. <br/>{{{$log['in_file']}}}
  81. @endif
  82. @if ($log['stack'])
  83. <div class="stack" id="stack{{{$key}}}"
  84. style="display: none; white-space: pre-wrap;">{{{ trim($log['stack']) }}}
  85. </div>
  86. @endif
  87. </td>
  88. </tr>
  89. @endforeach
  90. </tbody>
  91. </table>
  92. @endif
  93. <div class="p-3">
  94. @if($current_file)
  95. <a href="?dl={{ \Illuminate\Support\Facades\Crypt::encrypt($current_file) }}{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}">
  96. <span class="fa fa-download"></span> Download file
  97. </a>
  98. -
  99. <a id="clean-log"
  100. href="?clean={{ \Illuminate\Support\Facades\Crypt::encrypt($current_file) }}{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}">
  101. <span class="fa fa-sync"></span> Clean file
  102. </a>
  103. -
  104. <a id="delete-log"
  105. href="?del={{ \Illuminate\Support\Facades\Crypt::encrypt($current_file) }}{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}">
  106. <span class="fa fa-trash"></span> Delete file
  107. </a>
  108. @if(count($files) > 1)
  109. -
  110. <a id="delete-all-log"
  111. href="?delall=true{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}">
  112. <span class="fa fa-trash-alt"></span> Delete all files
  113. </a>
  114. @endif
  115. @endif
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. @endsection
  121. @section('js')
  122. <script type="text/javascript" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
  123. <script type="text/javascript" src="https://cdn.datatables.net/1.10.16/js/dataTables.bootstrap4.min.js"></script>
  124. <script>
  125. $(document).ready(function () {
  126. $('.table-container tr').on('click', function () {
  127. $('#' + $(this).data('display')).toggle();
  128. });
  129. $('#table-log').DataTable({
  130. "order": [$('#table-log').data('orderingIndex'), 'desc'],
  131. "stateSave": true,
  132. "stateSaveCallback": function (settings, data) {
  133. window.localStorage.setItem("datatable", JSON.stringify(data));
  134. },
  135. "stateLoadCallback": function (settings) {
  136. var data = JSON.parse(window.localStorage.getItem("datatable"));
  137. if (data) data.start = 0;
  138. return data;
  139. }
  140. });
  141. $('#delete-log, #clean-log, #delete-all-log').click(function () {
  142. return confirm('Are you sure?');
  143. });
  144. });
  145. </script>
  146. @endsection