1 | <?php namespace Arcanesoft\Foundation\Http\Controllers\Admin\System; |
||
20 | class LogViewerController extends Controller |
||
21 | { |
||
22 | /* ----------------------------------------------------------------- |
||
23 | | Trait |
||
24 | | ----------------------------------------------------------------- |
||
25 | */ |
||
26 | |||
27 | use JsonResponses; |
||
28 | |||
29 | /* ----------------------------------------------------------------- |
||
30 | | Properties |
||
31 | | ----------------------------------------------------------------- |
||
32 | */ |
||
33 | |||
34 | /** |
||
35 | * The LogViewer instance. |
||
36 | * |
||
37 | * @var \Arcanedev\LogViewer\Contracts\LogViewer |
||
38 | */ |
||
39 | protected $logViewer; |
||
40 | |||
41 | /** |
||
42 | * Logs per page. |
||
43 | * |
||
44 | * @var int |
||
45 | */ |
||
46 | protected $perPage = 30; |
||
47 | |||
48 | /* ----------------------------------------------------------------- |
||
49 | | Constructor |
||
50 | | ----------------------------------------------------------------- |
||
51 | */ |
||
52 | |||
53 | /** |
||
54 | * LogViewerController constructor. |
||
55 | * |
||
56 | * @param \Arcanedev\LogViewer\Contracts\LogViewer $logViewer |
||
57 | */ |
||
58 | public function __construct(LogViewerContract $logViewer) |
||
67 | |||
68 | /* ------------------------------------------------------------------------------------------------ |
||
69 | | Main Functions |
||
70 | | ------------------------------------------------------------------------------------------------ |
||
71 | */ |
||
72 | |||
73 | /** |
||
74 | * Show the LogViewer Dashboard. |
||
75 | * |
||
76 | * @return \Illuminate\View\View |
||
77 | */ |
||
78 | public function index() |
||
90 | |||
91 | /** |
||
92 | * List all logs. |
||
93 | * |
||
94 | * @param \Illuminate\Http\Request $request |
||
95 | * |
||
96 | * @return \Illuminate\View\View |
||
97 | */ |
||
98 | public function listLogs(Request $request) |
||
121 | |||
122 | /** |
||
123 | * Show the log entries by date. |
||
124 | * |
||
125 | * @param string $date |
||
126 | * |
||
127 | * @return \Illuminate\View\View |
||
128 | */ |
||
129 | public function show($date) |
||
143 | |||
144 | /** |
||
145 | * Filter the log entries by date and level. |
||
146 | * |
||
147 | * @param string $date |
||
148 | * @param string $level |
||
149 | * |
||
150 | * @return \Illuminate\View\View|\Illuminate\Http\RedirectResponse |
||
151 | */ |
||
152 | public function showByLevel($date, $level) |
||
172 | |||
173 | /** |
||
174 | * Show the log with the search query. |
||
175 | * |
||
176 | * @param string $date |
||
177 | * @param string $level |
||
178 | * @param \Illuminate\Http\Request $request |
||
179 | * |
||
180 | * @return \Illuminate\View\View |
||
181 | */ |
||
182 | public function search($date, $level = 'all', Request $request) |
||
196 | |||
197 | /** |
||
198 | * Download the log. |
||
199 | * |
||
200 | * @param string $date |
||
201 | * |
||
202 | * @return \Symfony\Component\HttpFoundation\BinaryFileResponse |
||
203 | */ |
||
204 | public function download($date) |
||
210 | |||
211 | /** |
||
212 | * Delete a log. |
||
213 | * |
||
214 | * @param string $date |
||
215 | * |
||
216 | * @return \Illuminate\Http\JsonResponse |
||
217 | */ |
||
218 | public function delete($date) |
||
235 | |||
236 | /* ----------------------------------------------------------------- |
||
237 | | Other Methods |
||
238 | | ----------------------------------------------------------------- |
||
239 | */ |
||
240 | |||
241 | /** |
||
242 | * Get a log or fail. |
||
243 | * |
||
244 | * @param string $date |
||
245 | * |
||
246 | * @return Log|null |
||
247 | */ |
||
248 | private function getLogOrFail($date) |
||
261 | |||
262 | /** |
||
263 | * Calculate the percentage. |
||
264 | * |
||
265 | * @param array $total |
||
266 | * @param array $names |
||
267 | * |
||
268 | * @return array |
||
269 | */ |
||
270 | private function calcPercentages(array $total, array $names) |
||
285 | } |
||
286 |