@@ -35,6 +35,40 @@ class Logging
3535 private array $ configLoggingSettings = [];
3636 private array $ emailReceivers = [];
3737 private string $ emailSender ;
38+ /**
39+ * @var string
40+ */
41+ private const PRIORITY = 'priority ' ;
42+
43+ /**
44+ * @var string
45+ */
46+ private const ERROR_TYPE = 'errorType ' ;
47+
48+ /**
49+ * @var string
50+ */
51+ private const ERROR_FILE = 'errorFile ' ;
52+
53+ /**
54+ * @var string
55+ */
56+ private const ERROR_LINE = 'errorLine ' ;
57+
58+ /**
59+ * @var string
60+ */
61+ private const TRACE = 'trace ' ;
62+
63+ /**
64+ * @var string
65+ */
66+ private const ERROR_MESSAGE = 'errorMessage ' ;
67+
68+ /**
69+ * @var string
70+ */
71+ private const SERVER_URL = 'server_url ' ;
3872
3973 public function __construct (
4074 private Logger $ logger ,
@@ -105,12 +139,12 @@ private function collectErrorExceptionData(Throwable $throwable): array
105139 $ errorMessage = $ throwable ->getMessage ();
106140
107141 return [
108- ' priority ' => $ priority ,
109- ' errorType ' => $ errorType ,
110- ' errorFile ' => $ errorFile ,
111- ' errorLine ' => $ errorLine ,
112- ' trace ' => $ traceAsString ,
113- ' errorMessage ' => $ errorMessage ,
142+ self :: PRIORITY => $ priority ,
143+ self :: ERROR_TYPE => $ errorType ,
144+ self :: ERROR_FILE => $ errorFile ,
145+ self :: ERROR_LINE => $ errorLine ,
146+ self :: TRACE => $ traceAsString ,
147+ self :: ERROR_MESSAGE => $ errorMessage ,
114148 ];
115149 }
116150
@@ -137,13 +171,13 @@ private function collectErrorExceptionExtraData(array $collectedExceptionData, R
137171 }
138172
139173 return [
140- ' server_url ' => $ serverUrl ,
141- 'url ' => $ url ,
142- 'file ' => $ collectedExceptionData [' errorFile ' ],
143- 'line ' => $ collectedExceptionData [' errorLine ' ],
144- 'error_type ' => $ collectedExceptionData [' errorType ' ],
145- ' trace ' => $ collectedExceptionData [' trace ' ],
146- 'request_data ' => $ this ->getRequestData ($ request ),
174+ self :: SERVER_URL => $ serverUrl ,
175+ 'url ' => $ url ,
176+ 'file ' => $ collectedExceptionData [self :: ERROR_FILE ],
177+ 'line ' => $ collectedExceptionData [self :: ERROR_LINE ],
178+ 'error_type ' => $ collectedExceptionData [self :: ERROR_TYPE ],
179+ self :: TRACE => $ collectedExceptionData [self :: TRACE ],
180+ 'request_data ' => $ this ->getRequestData ($ request ),
147181 ];
148182 }
149183
@@ -213,34 +247,38 @@ public function handleErrorException(Throwable $throwable, RequestInterface $req
213247 {
214248 $ collectedExceptionData = $ this ->collectErrorExceptionData ($ throwable );
215249 $ extra = $ this ->collectErrorExceptionExtraData ($ collectedExceptionData , $ request );
216- $ serverUrl = $ extra [' server_url ' ];
250+ $ serverUrl = $ extra [self :: SERVER_URL ];
217251
218252 try {
219253 if (
220254 $ this ->isExists (
221- $ collectedExceptionData [' errorFile ' ],
222- $ collectedExceptionData [' errorLine ' ],
223- $ collectedExceptionData [' errorMessage ' ],
255+ $ collectedExceptionData [self :: ERROR_FILE ],
256+ $ collectedExceptionData [self :: ERROR_LINE ],
257+ $ collectedExceptionData [self :: ERROR_MESSAGE ],
224258 $ extra ['url ' ],
225- $ collectedExceptionData [' errorType ' ]
259+ $ collectedExceptionData [self :: ERROR_TYPE ]
226260 )
227261 ) {
228262 return ;
229263 }
230264
231- unset($ extra ['server_url ' ]);
232- $ this ->logger ->log ($ collectedExceptionData ['priority ' ], $ collectedExceptionData ['errorMessage ' ], $ extra );
265+ unset($ extra [self ::SERVER_URL ]);
266+ $ this ->logger ->log (
267+ $ collectedExceptionData [self ::PRIORITY ],
268+ $ collectedExceptionData [self ::ERROR_MESSAGE ],
269+ $ extra
270+ );
233271 } catch (RuntimeException $ e ) {
234272 $ collectedExceptionData = $ this ->collectErrorExceptionData ($ e );
235273 $ extra = $ this ->collectErrorExceptionExtraData ($ collectedExceptionData , $ request );
236- unset($ extra [' server_url ' ]);
274+ unset($ extra [self :: SERVER_URL ]);
237275 }
238276
239277 $ this ->sendMail (
240- $ collectedExceptionData [' priority ' ],
241- $ collectedExceptionData [' errorMessage ' ],
278+ $ collectedExceptionData [self :: PRIORITY ],
279+ $ collectedExceptionData [self :: ERROR_MESSAGE ],
242280 $ extra ,
243- '[ ' . $ serverUrl . '] ' . $ collectedExceptionData [' errorType ' ] . ' has thrown '
281+ '[ ' . $ serverUrl . '] ' . $ collectedExceptionData [self :: ERROR_TYPE ] . ' has thrown '
244282 );
245283 }
246284}
0 commit comments