|
1 | 1 | <?php
|
2 | 2 |
|
3 | 3 | use KaririCode\Logging\LogLevel;
|
4 |
| -use KaririCode\Logging\Util\ConfigHelper; |
| 4 | +use KaririCode\Logging\Util\Config; |
5 | 5 |
|
6 | 6 | return [
|
7 |
| - 'default' => ConfigHelper::env('LOG_CHANNEL', 'file'), |
| 7 | + 'default' => Config::env('LOG_CHANNEL', 'file'), |
8 | 8 | 'channels' => [
|
9 | 9 | 'file' => [
|
10 |
| - 'level' => ConfigHelper::env('LOG_LEVEL', 'debug'), |
| 10 | + 'minLevel' => Config::env('LOG_LEVEL', 'debug'), |
11 | 11 | 'handlers' => [
|
12 | 12 | 'file' => [
|
13 |
| - 'with' => ['filePath' => ConfigHelper::storagePath('logs/file2.log')], |
| 13 | + 'with' => ['filePath' => Config::storagePath('logs/file2.log')], |
14 | 14 | ],
|
15 | 15 | ],
|
16 | 16 | 'processors' => [
|
17 |
| - 'introspection_processor' => [ |
18 |
| - 'class' => \KaririCode\Logging\Processor\IntrospectionProcessor::class, |
19 |
| - 'with' => [ |
20 |
| - 'stackDepth' => 7 |
21 |
| - ] |
22 |
| - ], |
| 17 | + 'introspection_processor', |
| 18 | + 'anonymizer_processor' |
23 | 19 | ],
|
24 | 20 | 'formatter' => [
|
25 | 21 | 'line' => [
|
|
30 | 26 | ],
|
31 | 27 | ],
|
32 | 28 | 'console' => [
|
33 |
| - 'level' => ConfigHelper::env('LOG_LEVEL', 'debug'), |
| 29 | + 'minLevel' => Config::env('LOG_LEVEL', 'debug'), |
34 | 30 | 'handlers' => ['console'],
|
35 | 31 | 'formatter' => [
|
36 | 32 | 'json' => [
|
|
42 | 38 |
|
43 | 39 | 'processors' => [
|
44 | 40 | 'introspection_processor',
|
| 41 | + 'anonymizer_processor' |
45 | 42 | ],
|
46 | 43 | ],
|
47 | 44 | 'syslog' => [
|
48 |
| - 'level' => ConfigHelper::env('LOG_LEVEL', 'debug'), |
| 45 | + 'minLevel' => Config::env('LOG_LEVEL', 'debug'), |
49 | 46 | 'handlers' => ['syslog'],
|
50 | 47 | ],
|
51 | 48 | 'slack' => [
|
52 |
| - 'level' => ConfigHelper::env('LOG_LEVEL', 'critical'), |
| 49 | + 'minLevel' => Config::env('LOG_LEVEL', 'critical'), |
53 | 50 | 'handlers' => ['slack'],
|
54 | 51 | 'formatter' => [
|
55 | 52 | 'json' => [
|
|
64 | 61 | ],
|
65 | 62 | ],
|
66 | 63 | 'async' => [
|
67 |
| - 'enabled' => ConfigHelper::env('ASYNC_LOG_ENABLED', true), |
68 |
| - 'batch_size' => ConfigHelper::env('ASYNC_LOG_BATCH_SIZE', 10), |
69 |
| - 'channel' => ConfigHelper::env('ASYNC_LOG_CHANNEL', 'file'), |
| 64 | + 'enabled' => Config::env('ASYNC_LOG_ENABLED', true), |
| 65 | + 'batch_size' => Config::env('ASYNC_LOG_BATCH_SIZE', 10), |
| 66 | + 'channel' => Config::env('ASYNC_LOG_CHANNEL', 'file'), |
70 | 67 | ],
|
71 | 68 | 'emergency' => [
|
72 |
| - 'path' => ConfigHelper::storagePath('logs/emergency.log'), |
73 |
| - 'level' => LogLevel::EMERGENCY, |
| 69 | + 'minLevel' => LogLevel::EMERGENCY, |
| 70 | + 'path' => Config::storagePath('logs/emergency.log'), |
74 | 71 | ],
|
75 | 72 | 'query' => [
|
76 |
| - 'enabled' => ConfigHelper::env('QUERY_LOG_ENABLED', false), |
77 |
| - 'channel' => ConfigHelper::env('QUERY_LOG_CHANNEL', 'file'), |
78 |
| - 'threshold' => ConfigHelper::env('QUERY_LOG_THRESHOLD', 100), // in milliseconds |
| 73 | + 'enabled' => Config::env('QUERY_LOG_ENABLED', false), |
| 74 | + 'channel' => Config::env('QUERY_LOG_CHANNEL', 'file'), |
| 75 | + 'threshold' => Config::env('QUERY_LOG_THRESHOLD', 100), // in milliseconds |
79 | 76 | 'handlers' => [
|
80 | 77 | 'console' => [
|
81 | 78 | 'with' => ['useColors' => true],
|
82 | 79 | ],
|
83 | 80 | 'file' => [
|
84 |
| - 'with' => ['filePath' => ConfigHelper::storagePath('logs/query.log')], |
| 81 | + 'with' => ['filePath' => Config::storagePath('logs/query.log')], |
85 | 82 | ],
|
86 | 83 | ],
|
87 | 84 | ],
|
88 | 85 | 'performance' => [
|
89 |
| - 'enabled' => ConfigHelper::env('PERFORMANCE_LOG_ENABLED', false), |
90 |
| - 'channel' => ConfigHelper::env('PERFORMANCE_LOG_CHANNEL', 'file'), |
91 |
| - 'threshold' => ConfigHelper::env('PERFORMANCE_LOG_THRESHOLD', 1000), // in milliseconds |
| 86 | + 'enabled' => Config::env('PERFORMANCE_LOG_ENABLED', false), |
| 87 | + 'channel' => Config::env('PERFORMANCE_LOG_CHANNEL', 'file'), |
| 88 | + 'threshold' => Config::env('PERFORMANCE_LOG_THRESHOLD', 1000), // in milliseconds |
92 | 89 | 'handlers' => [
|
93 | 90 | 'console' => [
|
94 | 91 | 'with' => ['useColors' => true],
|
95 | 92 | ],
|
96 | 93 | 'file' => [
|
97 |
| - 'with' => ['filePath' => ConfigHelper::storagePath('logs/performance.log')], |
| 94 | + 'with' => ['filePath' => Config::storagePath('logs/performance.log')], |
98 | 95 | ],
|
99 | 96 | ],
|
100 | 97 | 'processors' => [
|
|
104 | 101 | ],
|
105 | 102 | ],
|
106 | 103 | 'error' => [
|
107 |
| - 'enabled' => ConfigHelper::env('ERROR_LOG_ENABLED', true), |
108 |
| - 'channel' => ConfigHelper::env('ERROR_LOG_CHANNEL', 'file'), |
| 104 | + 'enabled' => Config::env('ERROR_LOG_ENABLED', true), |
| 105 | + 'channel' => Config::env('ERROR_LOG_CHANNEL', 'file'), |
109 | 106 | 'levels' => [
|
110 | 107 | LogLevel::ERROR,
|
111 | 108 | LogLevel::CRITICAL,
|
|
114 | 111 | ],
|
115 | 112 | ],
|
116 | 113 | 'log_cleaner' => [
|
117 |
| - 'enabled' => ConfigHelper::env('LOG_CLEANER_ENABLED', true), |
118 |
| - 'keep_days' => ConfigHelper::env('LOG_CLEANER_KEEP_DAYS', 30), |
| 114 | + 'enabled' => Config::env('LOG_CLEANER_ENABLED', true), |
| 115 | + 'keep_days' => Config::env('LOG_CLEANER_KEEP_DAYS', 30), |
119 | 116 | 'channels' => ['single', 'file'],
|
120 | 117 | ],
|
121 | 118 | 'handlers' => [
|
122 | 119 | 'file' => [
|
123 | 120 | 'class' => \KaririCode\Logging\Handler\FileHandler::class,
|
124 | 121 | 'with' => [
|
125 |
| - 'filePath' => ConfigHelper::storagePath('logs/file.log'), |
| 122 | + 'filePath' => Config::storagePath('logs/file.log'), |
126 | 123 | ],
|
127 | 124 | ],
|
128 | 125 | 'console' => [
|
|
143 | 140 | 'class' => \KaririCode\Logging\Handler\SlackHandler::class,
|
144 | 141 | 'with' => [
|
145 | 142 | 'slackClient' => \KaririCode\Logging\Util\SlackClient::create(
|
146 |
| - ConfigHelper::env('LOG_SLACK_WEBHOOK_URL'), |
| 143 | + Config::env('LOG_SLACK_WEBHOOK_URL'), |
147 | 144 | new \KaririCode\Logging\Resilience\CircuitBreaker(
|
148 |
| - ConfigHelper::env('CIRCUIT_BREAKER_FAILURE_THRESHOLD', 3), |
149 |
| - ConfigHelper::env('CIRCUIT_BREAKER_RESET_TIMEOUT', 60) |
| 145 | + Config::env('CIRCUIT_BREAKER_FAILURE_THRESHOLD', 3), |
| 146 | + Config::env('CIRCUIT_BREAKER_RESET_TIMEOUT', 60) |
150 | 147 | ),
|
151 | 148 | new \KaririCode\Logging\Resilience\Retry(
|
152 |
| - ConfigHelper::env('RETRY_MAX_ATTEMPTS', 3), |
153 |
| - ConfigHelper::env('RETRY_DELAY', 1000), |
154 |
| - ConfigHelper::env('RETRY_MULTIPLIER', 2), |
155 |
| - ConfigHelper::env('RETRY_JITTER', 100) |
| 149 | + Config::env('RETRY_MAX_ATTEMPTS', 3), |
| 150 | + Config::env('RETRY_DELAY', 1000), |
| 151 | + Config::env('RETRY_MULTIPLIER', 2), |
| 152 | + Config::env('RETRY_JITTER', 100) |
156 | 153 | ),
|
157 | 154 | new \KaririCode\Logging\Resilience\Fallback(),
|
158 | 155 | new \KaririCode\Logging\Util\CurlClient()
|
|
167 | 164 | 'processors' => [
|
168 | 165 | 'introspection_processor' => [
|
169 | 166 | 'class' => \KaririCode\Logging\Processor\IntrospectionProcessor::class,
|
170 |
| - 'level' => LogLevel::DEBUG, |
| 167 | + 'with' => [ |
| 168 | + 'stackDepth' => 7 |
| 169 | + ] |
171 | 170 | ],
|
172 | 171 | 'memory_usage_processor' => [
|
173 | 172 | 'class' => \KaririCode\Logging\Processor\Metric\MemoryUsageProcessor::class,
|
174 |
| - 'level' => LogLevel::DEBUG, |
175 | 173 | ],
|
176 | 174 | 'execution_time_processor' => [
|
177 | 175 | 'class' => \KaririCode\Logging\Processor\Metric\ExecutionTimeProcessor::class,
|
178 |
| - 'level' => LogLevel::DEBUG, |
179 | 176 | ],
|
180 | 177 | 'cpu_usage_processor' => [
|
181 | 178 | 'class' => \KaririCode\Logging\Processor\Metric\CpuUsageProcessor::class,
|
182 |
| - 'level' => LogLevel::DEBUG, |
183 | 179 | ],
|
184 | 180 | 'metrics_processor' => [
|
185 | 181 | 'class' => \KaririCode\Logging\Processor\MetricsProcessor::class,
|
186 |
| - 'level' => LogLevel::DEBUG, |
187 | 182 | ],
|
188 | 183 | 'web_processor' => [
|
189 | 184 | 'class' => \KaririCode\Logging\Processor\WebProcessor::class,
|
190 |
| - 'level' => LogLevel::INFO, |
| 185 | + ], |
| 186 | + 'anonymizer_processor' => [ |
| 187 | + 'class' => \KaririCode\Logging\Processor\AnonymizerProcessor::class, |
| 188 | + 'with' => [ |
| 189 | + 'anonymizer' => new \KaririCode\Logging\Security\Anonymizer([ |
| 190 | + 'phone' => new \KaririCode\Logging\Security\Anonymizer\PhoneAnonymizer(), |
| 191 | + 'ip' => new \KaririCode\Logging\Security\Anonymizer\IpAnonymizer(), |
| 192 | + ]), |
| 193 | + ], |
| 194 | + ], |
| 195 | + 'encryption_processor' => [ |
| 196 | + 'class' => \KaririCode\Logging\Processor\EncryptionProcessor::class, |
| 197 | + 'with' => [ |
| 198 | + 'encryptor' => new \KaririCode\Logging\Security\Encryptor(Config::env('LOG_ENCRYPTION_KEY')), |
| 199 | + ], |
191 | 200 | ],
|
192 | 201 | ],
|
193 | 202 | 'formatters' => [
|
|
0 commit comments