log.blade.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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) }}"
  72. class="list-group-item @if ($current_file == $file) llv-active @endif">
  73. {{$file}}
  74. </a>
  75. @endforeach
  76. </div>
  77. @endif
  78. </div>
  79. @endforeach
  80. @foreach($files as $file)
  81. <a href="?l={{ \Illuminate\Support\Facades\Crypt::encrypt($file) }}"
  82. class="list-group-item @if ($current_file == $file) llv-active @endif">
  83. {{$file}}
  84. </a>
  85. @endforeach
  86. </div>
  87. </div>
  88. <div class="col-10 table-container">
  89. @if ($logs === NULL)
  90. <div>
  91. Log file >50M, please download it.
  92. </div>
  93. @else
  94. <table id="table-log" class="table table-striped" data-ordering-index="{{ $standardFormat ? 2 : 0 }}">
  95. <thead>
  96. <tr>
  97. @if ($standardFormat)
  98. <th>Level</th>
  99. <th>Context</th>
  100. <th>Date</th>
  101. @else
  102. <th>Line number</th>
  103. @endif
  104. <th>Content</th>
  105. </tr>
  106. </thead>
  107. <tbody>
  108. @foreach($logs as $key => $log)
  109. <tr data-display="stack{{{$key}}}">
  110. @if ($standardFormat)
  111. <td class="nowrap text-{{{$log['level_class']}}}">
  112. <span class="fa fa-{{{$log['level_img']}}}"
  113. aria-hidden="true"></span>&nbsp;&nbsp;{{$log['level']}}
  114. </td>
  115. <td class="text">{{$log['context']}}</td>
  116. @endif
  117. <td class="date">{{{$log['date']}}}</td>
  118. <td class="text">
  119. @if ($log['stack'])
  120. <button type="button"
  121. class="float-right expand btn btn-outline-dark btn-sm mb-2 ml-2"
  122. data-display="stack{{{$key}}}">
  123. <span class="fa fa-search"></span>
  124. </button>
  125. @endif
  126. {{{$log['text']}}}
  127. @if (isset($log['in_file']))
  128. <br/>{{{$log['in_file']}}}
  129. @endif
  130. @if ($log['stack'])
  131. <div class="stack" id="stack{{{$key}}}"
  132. style="display: none; white-space: pre-wrap;">{{{ trim($log['stack']) }}}
  133. </div>
  134. @endif
  135. </td>
  136. </tr>
  137. @endforeach
  138. </tbody>
  139. </table>
  140. @endif
  141. <div class="p-3">
  142. @if($current_file)
  143. <a href="?dl={{ \Illuminate\Support\Facades\Crypt::encrypt($current_file) }}{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}">
  144. <span class="fa fa-download"></span> 下 载
  145. </a>
  146. -
  147. <a id="clean-log"
  148. href="?clean={{ \Illuminate\Support\Facades\Crypt::encrypt($current_file) }}{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}">
  149. <span class="fa fa-sync"></span> 清 空
  150. </a>
  151. -
  152. <a id="delete-log"
  153. href="?del={{ \Illuminate\Support\Facades\Crypt::encrypt($current_file) }}{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}">
  154. <span class="fa fa-trash"></span> 删 除
  155. </a>
  156. @if(count($files) > 1)
  157. -
  158. <a id="delete-all-log"
  159. href="?delall=true{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}">
  160. <span class="fa fa-trash-alt"></span> 删除全部
  161. </a>
  162. @endif
  163. @endif
  164. </div>
  165. </div>
  166. </div>
  167. </div>
  168. <!-- jQuery for Bootstrap -->
  169. <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
  170. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
  171. <!-- FontAwesome -->
  172. <script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
  173. <!-- Datatables -->
  174. <script type="text/javascript" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
  175. <script type="text/javascript" src="https://cdn.datatables.net/1.10.16/js/dataTables.bootstrap4.min.js"></script>
  176. <script type="text/javascript">
  177. $(document).ready(function () {
  178. $('.table-container tr').on('click', function () {
  179. $('#' + $(this).data('display')).toggle();
  180. });
  181. $('#table-log').DataTable({
  182. "order": [$('#table-log').data('orderingIndex'), 'desc'],
  183. "stateSave": true,
  184. "stateSaveCallback": function (settings, data) {
  185. window.localStorage.setItem("datatable", JSON.stringify(data));
  186. },
  187. "stateLoadCallback": function (settings) {
  188. var data = JSON.parse(window.localStorage.getItem("datatable"));
  189. if (data) data.start = 0;
  190. return data;
  191. },
  192. "language": {
  193. "lengthMenu": "每页 _MENU_ 条",
  194. "paginate": {
  195. "previous": "上一页",
  196. "next": "下一页"
  197. },
  198. "search": "搜索",
  199. "info": "第 _PAGE_ 页,共 _PAGES_ 页"
  200. }
  201. });
  202. $('#delete-log, #clean-log, #delete-all-log').click(function () {
  203. return confirm('确定继续吗?');
  204. });
  205. });
  206. </script>
  207. </body>
  208. </html>