log.blade.php 6.5 KB

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