log.blade.php 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <!DOCTYPE html>
  2. <html lang="{{app()->getLocale()}}">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  6. <title>系统运行日志</title>
  7. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  8. <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/dataTables.bootstrap4.min.css">
  9. <style>
  10. body {
  11. padding: 25px;
  12. }
  13. h1 {
  14. font-size: 1.5em;
  15. margin-top: 0;
  16. }
  17. #table-log {
  18. font-size: 0.85rem;
  19. }
  20. .sidebar {
  21. font-size: 0.85rem;
  22. line-height: 1;
  23. }
  24. .btn {
  25. font-size: 0.7rem;
  26. }
  27. .stack {
  28. font-size: 0.85em;
  29. }
  30. .date {
  31. min-width: 75px;
  32. }
  33. .text {
  34. word-break: break-all;
  35. }
  36. a.llv-active {
  37. z-index: 2;
  38. background-color: #f5f5f5;
  39. border-color: #777;
  40. }
  41. .list-group-item {
  42. word-wrap: break-word;
  43. }
  44. .folder {
  45. padding-top: 15px;
  46. }
  47. .div-scroll {
  48. height: 80vh;
  49. overflow: hidden auto;
  50. }
  51. .nowrap {
  52. white-space: nowrap;
  53. }
  54. </style>
  55. </head>
  56. <body>
  57. <div class="container-fluid">
  58. <div class="row">
  59. <div class="col sidebar mb-3">
  60. <h1>系统运行日志</h1>
  61. <div class="list-group div-scroll">
  62. @foreach($folders as $folder)
  63. <div class="list-group-item">
  64. <a href="?f={{ \Illuminate\Support\Facades\Crypt::encrypt($folder) }}">
  65. <span class="fa fa-folder"></span> {{$folder}}
  66. </a>
  67. @if ($current_folder == $folder)
  68. <div class="list-group folder">
  69. @foreach($folder_files as $file)
  70. <a href="?l={{ \Illuminate\Support\Facades\Crypt::encrypt($file) }}&f={{ \Illuminate\Support\Facades\Crypt::encrypt($folder) }}" class="list-group-item @if ($current_file == $file) llv-active @endif">
  71. {{$file}}
  72. </a>
  73. @endforeach
  74. </div>
  75. @endif
  76. </div>
  77. @endforeach
  78. @foreach($files as $file)
  79. <a href="?l={{ \Illuminate\Support\Facades\Crypt::encrypt($file) }}" class="list-group-item @if ($current_file == $file) llv-active @endif">
  80. {{$file}}
  81. </a>
  82. @endforeach
  83. </div>
  84. </div>
  85. <div class="col-10 table-container">
  86. @if ($logs === null)
  87. <div>
  88. Log file >50M, please download it.
  89. </div>
  90. @else
  91. <table id="table-log" class="table table-striped" data-ordering-index="{{ $standardFormat ? 2 : 0 }}">
  92. <thead>
  93. <tr>
  94. @if ($standardFormat)
  95. <th>Level</th>
  96. <th>Context</th>
  97. <th>Date</th>
  98. @else
  99. <th>Line number</th>
  100. @endif
  101. <th>Content</th>
  102. </tr>
  103. </thead>
  104. <tbody>
  105. @foreach($logs as $key => $log)
  106. <tr data-display="stack{{{$key}}}">
  107. @if ($standardFormat)
  108. <td class="nowrap text-{{{$log['level_class']}}}">
  109. <span class="fa fa-{{{$log['level_img']}}}" aria-hidden="true"></span>&nbsp;&nbsp;{{$log['level']}}
  110. </td>
  111. <td class="text">{{$log['context']}}</td>
  112. @endif
  113. <td class="date">{{{$log['date']}}}</td>
  114. <td class="text">
  115. @if ($log['stack'])
  116. <button type="button" class="float-right expand btn btn-outline-dark btn-sm mb-2 ml-2" data-display="stack{{{$key}}}">
  117. <span class="fa fa-search"></span>
  118. </button>
  119. @endif
  120. {{{$log['text']}}}
  121. @if (isset($log['in_file']))
  122. <br/>{{{$log['in_file']}}}
  123. @endif
  124. @if ($log['stack'])
  125. <div class="stack" id="stack{{{$key}}}" style="display: none; white-space: pre-wrap;">{{{ trim($log['stack']) }}}
  126. </div>
  127. @endif
  128. </td>
  129. </tr>
  130. @endforeach
  131. </tbody>
  132. </table>
  133. @endif
  134. <div class="p-3">
  135. @if($current_file)
  136. <a href="?dl={{ \Illuminate\Support\Facades\Crypt::encrypt($current_file) }}{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}"><span class="fa fa-download"></span> 下载 </a>
  137. -
  138. <a id="clean-log" href="?clean={{ \Illuminate\Support\Facades\Crypt::encrypt($current_file) }}{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}"><span class="fa fa-sync"></span> 清空 </a>
  139. -
  140. <a id="delete-log" href="?del={{ \Illuminate\Support\Facades\Crypt::encrypt($current_file) }}{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}"><span class="fa fa-trash"></span> 删除 </a>
  141. @if(count($files) > 1)
  142. -
  143. <a id="delete-all-log" href="?delall=true{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}"><span class="fa fa-trash-alt"></span> 删除全部 </a>
  144. @endif
  145. @endif
  146. </div>
  147. </div>
  148. </div>
  149. </div>
  150. <!-- jQuery for Bootstrap -->
  151. <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
  152. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
  153. <!-- FontAwesome -->
  154. <script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
  155. <!-- Datatables -->
  156. <script type="text/javascript" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
  157. <script type="text/javascript" src="https://cdn.datatables.net/1.10.16/js/dataTables.bootstrap4.min.js"></script>
  158. <script>
  159. $(document).ready(function () {
  160. $('.table-container tr').on('click', function () {
  161. $('#' + $(this).data('display')).toggle();
  162. });
  163. $('#table-log').DataTable({
  164. "order": [$('#table-log').data('orderingIndex'), 'desc'],
  165. "stateSave": true,
  166. "stateSaveCallback": function (settings, data) {
  167. window.localStorage.setItem("datatable", JSON.stringify(data));
  168. },
  169. "stateLoadCallback": function (settings) {
  170. var data = JSON.parse(window.localStorage.getItem("datatable"));
  171. if (data) data.start = 0;
  172. return data;
  173. },
  174. "language": {
  175. "lengthMenu": "每页 _MENU_ 条",
  176. "paginate": {
  177. "previous": "上一页",
  178. "next": "下一页"
  179. },
  180. "search": "搜索",
  181. "info": "第 _PAGE_ 页,共 _PAGES_ 页"
  182. }
  183. });
  184. $('#delete-log, #clean-log, #delete-all-log').click(function () {
  185. return confirm('确定继续吗?');
  186. });
  187. });
  188. </script>
  189. </body>
  190. </html>