1 | <?php namespace Arcanesoft\Foundation\Http\Controllers\Admin\System; |
||
18 | class LogViewerController extends Controller |
||
19 | { |
||
20 | /* ------------------------------------------------------------------------------------------------ |
||
21 | | Traits |
||
22 | | ------------------------------------------------------------------------------------------------ |
||
23 | */ |
||
24 | use Notifyable; |
||
25 | |||
26 | /* ------------------------------------------------------------------------------------------------ |
||
27 | | Properties |
||
28 | | ------------------------------------------------------------------------------------------------ |
||
29 | */ |
||
30 | /** |
||
31 | * The LogViewer instance. |
||
32 | * |
||
33 | * @var \Arcanedev\LogViewer\Contracts\LogViewer |
||
34 | */ |
||
35 | protected $logViewer; |
||
36 | |||
37 | /** |
||
38 | * Logs per page. |
||
39 | * |
||
40 | * @var int |
||
41 | */ |
||
42 | protected $perPage = 30; |
||
43 | |||
44 | /* ------------------------------------------------------------------------------------------------ |
||
45 | | Constructor |
||
46 | | ------------------------------------------------------------------------------------------------ |
||
47 | */ |
||
48 | /** |
||
49 | * LogViewerController constructor. |
||
50 | * |
||
51 | * @param \Arcanedev\LogViewer\Contracts\LogViewer $logViewer |
||
52 | */ |
||
53 | public function __construct(LogViewerContract $logViewer) |
||
62 | |||
63 | /* ------------------------------------------------------------------------------------------------ |
||
64 | | Main Functions |
||
65 | | ------------------------------------------------------------------------------------------------ |
||
66 | */ |
||
67 | /** |
||
68 | * Show the LogViewer Dashboard. |
||
69 | * |
||
70 | * @return \Illuminate\View\View |
||
71 | */ |
||
72 | public function index() |
||
84 | |||
85 | /** |
||
86 | * List all logs. |
||
87 | * |
||
88 | * @param \Illuminate\Http\Request $request |
||
89 | * |
||
90 | * @return \Illuminate\View\View |
||
91 | */ |
||
92 | public function listLogs(Request $request) |
||
115 | |||
116 | /** |
||
117 | * Show the log entries by date. |
||
118 | * |
||
119 | * @param string $date |
||
120 | * |
||
121 | * @return \Illuminate\View\View |
||
122 | */ |
||
123 | public function show($date) |
||
137 | |||
138 | /** |
||
139 | * Filter the log entries by date and level. |
||
140 | * |
||
141 | * @param string $date |
||
142 | * @param string $level |
||
143 | * |
||
144 | * @return \Illuminate\View\View|\Illuminate\Http\RedirectResponse |
||
145 | */ |
||
146 | public function showByLevel($date, $level) |
||
167 | |||
168 | /** |
||
169 | * Download the log. |
||
170 | * |
||
171 | * @param string $date |
||
172 | * |
||
173 | * @return \Symfony\Component\HttpFoundation\BinaryFileResponse |
||
174 | */ |
||
175 | public function download($date) |
||
181 | |||
182 | /** |
||
183 | * Delete a log. |
||
184 | * |
||
185 | * @param \Illuminate\Http\Request $request |
||
186 | * |
||
187 | * @return \Illuminate\Http\JsonResponse |
||
188 | */ |
||
189 | public function delete(Request $request) |
||
209 | |||
210 | /* ------------------------------------------------------------------------------------------------ |
||
211 | | Other Functions |
||
212 | | ------------------------------------------------------------------------------------------------ |
||
213 | */ |
||
214 | /** |
||
215 | * Get a log or fail. |
||
216 | * |
||
217 | * @param string $date |
||
218 | * |
||
219 | * @return Log|null |
||
220 | */ |
||
221 | private function getLogOrFail($date) |
||
234 | |||
235 | /** |
||
236 | * Calculate the percentage. |
||
237 | * |
||
238 | * @param array $total |
||
239 | * @param array $names |
||
240 | * |
||
241 | * @return array |
||
242 | */ |
||
243 | private function calcPercentages(array $total, array $names) |
||
258 | } |
||
259 |