1
|
|
|
<?php namespace Arcanedev\LogViewer\Providers; |
2
|
|
|
|
3
|
|
|
use Arcanedev\LogViewer\{Contracts, LogViewer, Utilities}; |
4
|
|
|
use Arcanedev\Support\Providers\ServiceProvider; |
5
|
|
|
use Illuminate\Contracts\Support\DeferrableProvider; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class DeferredServicesProvider |
9
|
|
|
* |
10
|
|
|
* @package Arcanedev\LogViewer\Providers |
11
|
|
|
* @author ARCANEDEV <[email protected]> |
12
|
|
|
*/ |
13
|
|
|
class DeferredServicesProvider extends ServiceProvider implements DeferrableProvider |
14
|
|
|
{ |
15
|
|
|
/* ----------------------------------------------------------------- |
16
|
|
|
| Main Methods |
17
|
|
|
| ----------------------------------------------------------------- |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Register the service provider. |
22
|
|
|
*/ |
23
|
288 |
|
public function register(): void |
24
|
|
|
{ |
25
|
288 |
|
$this->registerLogViewer(); |
26
|
288 |
|
$this->registerLogLevels(); |
27
|
288 |
|
$this->registerStyler(); |
28
|
288 |
|
$this->registerLogMenu(); |
29
|
288 |
|
$this->registerFilesystem(); |
30
|
288 |
|
$this->registerFactory(); |
31
|
288 |
|
$this->registerChecker(); |
32
|
288 |
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Get the services provided by the provider. |
36
|
|
|
* |
37
|
|
|
* @return array |
38
|
|
|
*/ |
39
|
4 |
|
public function provides(): array |
40
|
|
|
{ |
41
|
|
|
return [ |
42
|
4 |
|
Contracts\LogViewer::class, |
43
|
|
|
Contracts\Utilities\LogLevels::class, |
44
|
|
|
Contracts\Utilities\LogStyler::class, |
45
|
|
|
Contracts\Utilities\LogMenu::class, |
46
|
|
|
Contracts\Utilities\Filesystem::class, |
47
|
|
|
Contracts\Utilities\Factory::class, |
48
|
|
|
Contracts\Utilities\LogChecker::class, |
49
|
|
|
]; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/* ----------------------------------------------------------------- |
53
|
|
|
| LogViewer Utilities |
54
|
|
|
| ----------------------------------------------------------------- |
55
|
|
|
*/ |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Register the log viewer service. |
59
|
|
|
*/ |
60
|
288 |
|
private function registerLogViewer(): void |
61
|
|
|
{ |
62
|
288 |
|
$this->singleton(Contracts\LogViewer::class, LogViewer::class); |
63
|
288 |
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Register the log levels. |
67
|
|
|
*/ |
68
|
288 |
|
private function registerLogLevels(): void |
69
|
|
|
{ |
70
|
|
|
$this->singleton(Contracts\Utilities\LogLevels::class, function ($app) { |
71
|
172 |
|
return new Utilities\LogLevels( |
72
|
172 |
|
$app['translator'], |
73
|
172 |
|
$app['config']->get('log-viewer.locale') |
74
|
|
|
); |
75
|
288 |
|
}); |
76
|
288 |
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Register the log styler. |
80
|
|
|
*/ |
81
|
288 |
|
private function registerStyler(): void |
82
|
|
|
{ |
83
|
288 |
|
$this->singleton(Contracts\Utilities\LogStyler::class, Utilities\LogStyler::class); |
84
|
288 |
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Register the log menu builder. |
88
|
|
|
*/ |
89
|
288 |
|
private function registerLogMenu(): void |
90
|
|
|
{ |
91
|
288 |
|
$this->singleton(Contracts\Utilities\LogMenu::class, Utilities\LogMenu::class); |
92
|
288 |
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Register the log filesystem. |
96
|
|
|
*/ |
97
|
288 |
|
private function registerFilesystem(): void |
98
|
|
|
{ |
99
|
|
|
$this->singleton(Contracts\Utilities\Filesystem::class, function ($app) { |
100
|
|
|
/** @var \Illuminate\Config\Repository $config */ |
101
|
248 |
|
$config = $app['config']; |
102
|
248 |
|
$filesystem = new Utilities\Filesystem($app['files'], $config->get('log-viewer.storage-path')); |
103
|
|
|
|
104
|
248 |
|
return $filesystem->setPattern( |
105
|
248 |
|
$config->get('log-viewer.pattern.prefix', Utilities\Filesystem::PATTERN_PREFIX), |
106
|
248 |
|
$config->get('log-viewer.pattern.date', Utilities\Filesystem::PATTERN_DATE), |
107
|
248 |
|
$config->get('log-viewer.pattern.extension', Utilities\Filesystem::PATTERN_EXTENSION) |
108
|
|
|
); |
109
|
288 |
|
}); |
110
|
288 |
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Register the log factory class. |
114
|
|
|
*/ |
115
|
288 |
|
private function registerFactory(): void |
116
|
|
|
{ |
117
|
288 |
|
$this->singleton(Contracts\Utilities\Factory::class, Utilities\Factory::class); |
118
|
288 |
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Register the log checker service. |
122
|
|
|
*/ |
123
|
288 |
|
private function registerChecker(): void |
124
|
|
|
{ |
125
|
288 |
|
$this->singleton(Contracts\Utilities\LogChecker::class, Utilities\LogChecker::class); |
126
|
288 |
|
} |
127
|
|
|
} |
128
|
|
|
|