1 | <?php namespace Arcanedev\LogViewer\Utilities; |
||
15 | class Factory implements FactoryInterface |
||
16 | { |
||
17 | /* ------------------------------------------------------------------------------------------------ |
||
18 | | Properties |
||
19 | | ------------------------------------------------------------------------------------------------ |
||
20 | */ |
||
21 | /** |
||
22 | * The filesystem instance. |
||
23 | * |
||
24 | * @var \Arcanedev\LogViewer\Contracts\FilesystemInterface |
||
25 | */ |
||
26 | protected $filesystem; |
||
27 | |||
28 | /** |
||
29 | * @var \Arcanedev\LogViewer\Contracts\LogLevelsInterface |
||
30 | */ |
||
31 | private $levels; |
||
32 | |||
33 | /* ------------------------------------------------------------------------------------------------ |
||
34 | | Constructor |
||
35 | | ------------------------------------------------------------------------------------------------ |
||
36 | */ |
||
37 | /** |
||
38 | * Create a new instance. |
||
39 | * |
||
40 | * @param \Arcanedev\LogViewer\Contracts\FilesystemInterface $filesystem |
||
41 | * @param \Arcanedev\LogViewer\Contracts\LogLevelsInterface $levels |
||
42 | */ |
||
43 | 888 | public function __construct( |
|
44 | FilesystemInterface $filesystem, |
||
45 | LogLevelsInterface $levels |
||
46 | ) { |
||
47 | 888 | $this->setFilesystem($filesystem); |
|
48 | 888 | $this->setLevels($levels); |
|
49 | 888 | } |
|
50 | |||
51 | /* ------------------------------------------------------------------------------------------------ |
||
52 | | Getter & Setters |
||
53 | | ------------------------------------------------------------------------------------------------ |
||
54 | */ |
||
55 | /** |
||
56 | * Get the filesystem instance. |
||
57 | * |
||
58 | * @return \Arcanedev\LogViewer\Contracts\FilesystemInterface |
||
59 | */ |
||
60 | 12 | public function getFilesystem() |
|
61 | { |
||
62 | 12 | return $this->filesystem; |
|
63 | } |
||
64 | |||
65 | /** |
||
66 | * Set the filesystem instance. |
||
67 | * |
||
68 | * @param \Arcanedev\LogViewer\Contracts\FilesystemInterface $filesystem |
||
69 | * |
||
70 | * @return self |
||
71 | */ |
||
72 | 888 | public function setFilesystem(FilesystemInterface $filesystem) |
|
73 | { |
||
74 | 888 | $this->filesystem = $filesystem; |
|
75 | |||
76 | 888 | return $this; |
|
77 | } |
||
78 | |||
79 | /** |
||
80 | * Get the log levels instance. |
||
81 | * |
||
82 | * @return \Arcanedev\LogViewer\Contracts\LogLevelsInterface |
||
83 | */ |
||
84 | 12 | public function getLevels() |
|
88 | |||
89 | /** |
||
90 | * Set the log levels instance. |
||
91 | * |
||
92 | * @param \Arcanedev\LogViewer\Contracts\LogLevelsInterface $levels |
||
93 | * |
||
94 | * @return self |
||
95 | */ |
||
96 | 888 | public function setLevels(LogLevelsInterface $levels) |
|
102 | |||
103 | /** |
||
104 | * Set the log storage path. |
||
105 | * |
||
106 | * @param string $storagePath |
||
107 | * |
||
108 | * @return self |
||
109 | */ |
||
110 | 24 | public function setPath($storagePath) |
|
116 | |||
117 | /** |
||
118 | * Get the log pattern. |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | 24 | public function getPattern() |
|
126 | |||
127 | /** |
||
128 | * Set the log pattern. |
||
129 | * |
||
130 | * @param string $date |
||
131 | * @param string $prefix |
||
132 | * @param string $extension |
||
133 | * |
||
134 | * @return self |
||
135 | */ |
||
136 | 24 | public function setPattern( |
|
145 | |||
146 | /** |
||
147 | * Get all logs. |
||
148 | * |
||
149 | * @return \Arcanedev\LogViewer\Entities\LogCollection |
||
150 | */ |
||
151 | 516 | public function logs() |
|
155 | |||
156 | /* ------------------------------------------------------------------------------------------------ |
||
157 | | Main Functions |
||
158 | | ------------------------------------------------------------------------------------------------ |
||
159 | */ |
||
160 | /** |
||
161 | * Get all logs. (alias) |
||
162 | * |
||
163 | * @return \Arcanedev\LogViewer\Entities\LogCollection |
||
164 | */ |
||
165 | 24 | public function all() |
|
169 | |||
170 | /** |
||
171 | * Paginate all logs. |
||
172 | * |
||
173 | * @param int $perPage |
||
174 | * |
||
175 | * @return \Illuminate\Pagination\LengthAwarePaginator |
||
176 | */ |
||
177 | 24 | public function paginate($perPage = 30) |
|
181 | |||
182 | /** |
||
183 | * Get a log by date. |
||
184 | * |
||
185 | * @param string $date |
||
186 | * |
||
187 | * @return \Arcanedev\LogViewer\Entities\Log |
||
188 | */ |
||
189 | 72 | public function log($date) |
|
193 | |||
194 | /** |
||
195 | * Get a log by date (alias). |
||
196 | * |
||
197 | * @param string $date |
||
198 | * |
||
199 | * @return \Arcanedev\LogViewer\Entities\Log |
||
200 | */ |
||
201 | 12 | public function get($date) |
|
205 | |||
206 | /** |
||
207 | * Get log entries. |
||
208 | * |
||
209 | * @param string $date |
||
210 | * @param string $level |
||
211 | * |
||
212 | * @return \Arcanedev\LogViewer\Entities\LogEntryCollection |
||
213 | */ |
||
214 | 60 | public function entries($date, $level = 'all') |
|
218 | |||
219 | /** |
||
220 | * Get logs statistics. |
||
221 | * |
||
222 | * @return array |
||
223 | */ |
||
224 | 156 | public function stats() |
|
228 | |||
229 | /** |
||
230 | * Get logs statistics table. |
||
231 | * |
||
232 | * @param string|null $locale |
||
233 | * |
||
234 | * @return \Arcanedev\LogViewer\Tables\StatsTable |
||
235 | */ |
||
236 | 60 | public function statsTable($locale = null) |
|
240 | |||
241 | /** |
||
242 | * List the log files (dates). |
||
243 | * |
||
244 | * @return array |
||
245 | */ |
||
246 | 36 | public function dates() |
|
250 | |||
251 | /** |
||
252 | * Get logs count. |
||
253 | * |
||
254 | * @return int |
||
255 | */ |
||
256 | 36 | public function count() |
|
260 | |||
261 | /** |
||
262 | * Get total log entries. |
||
263 | * |
||
264 | * @param string $level |
||
265 | * |
||
266 | * @return int |
||
267 | */ |
||
268 | 48 | public function total($level = 'all') |
|
272 | |||
273 | /** |
||
274 | * Get tree menu. |
||
275 | * |
||
276 | * @param bool|false $trans |
||
277 | * |
||
278 | * @return array |
||
279 | */ |
||
280 | 24 | public function tree($trans = false) |
|
284 | |||
285 | /** |
||
286 | * Get tree menu. |
||
287 | * |
||
288 | * @param bool|true $trans |
||
289 | * |
||
290 | * @return array |
||
291 | */ |
||
292 | 36 | public function menu($trans = true) |
|
296 | |||
297 | /* ------------------------------------------------------------------------------------------------ |
||
298 | | Check Functions |
||
299 | | ------------------------------------------------------------------------------------------------ |
||
300 | */ |
||
301 | /** |
||
302 | * Determine if the log folder is empty or not. |
||
303 | * |
||
304 | * @return bool |
||
305 | */ |
||
306 | 24 | public function isEmpty() |
|
310 | } |
||
311 |