mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°4261 - code review with @PirGoif
This commit is contained in:
@@ -1157,6 +1157,14 @@ class ExceptionLog extends LogAPI
|
||||
$aContext['exception class'] = get_class($oException);
|
||||
}
|
||||
|
||||
if (empty($aContext['file'])) {
|
||||
$aContext['file'] = $oException->getFile();
|
||||
}
|
||||
|
||||
if (empty($aContext['line'])) {
|
||||
$aContext['line'] =$oException->getLine();
|
||||
}
|
||||
|
||||
self::Log($sLevel, $oException->getMessage(), get_class($oException), $aContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,8 +88,6 @@ class ExceptionListener implements ContainerAwareInterface
|
||||
// Log exception in iTop log
|
||||
\ExceptionLog::LogException($oException, [
|
||||
'uri' => $oEvent->getRequest()->getUri(),
|
||||
'file' => $oException->getFile(),
|
||||
'line' => $oException->getLine(),
|
||||
]);
|
||||
|
||||
// Prepare data for template
|
||||
|
||||
@@ -72,10 +72,13 @@ class ExceptionLogTest extends ItopDataTestCase
|
||||
$aContext = ['contextKey1' => 'value'];
|
||||
|
||||
foreach ($aLevels as $i => $sLevel) {
|
||||
$oException = new $aExceptions[$i]("Iteration number $i");
|
||||
|
||||
$sExpectedFile=__FILE__;
|
||||
$oException = new $aExceptions[$i]("Iteration number $i"); $sExpectedLine = __LINE__; //Both should remain on the same line
|
||||
|
||||
$iExpectedWriteNumber = $aExpectedWriteNumber[$i];
|
||||
$iExpectedDbWriteNumber = $aExpectedDbWriteNumber[$i];
|
||||
$aExpectedFileContext = array_merge($aContext, ['exception class' => get_class($oException)]); //The context is preserved, and, if the key 'exception class' is not yet in the array, it is added
|
||||
$aExpectedFileContext = array_merge($aContext, ['exception class' => get_class($oException), 'file' => $sExpectedFile, 'line' => $sExpectedLine]); //The context is preserved, and, if the key 'exception class' is not yet in the array, it is added
|
||||
$mockFileLog->expects($this->exactly($iExpectedWriteNumber))
|
||||
->method($sLevel)
|
||||
->with($oException->GetMessage(), $sChannel, $aExpectedFileContext)
|
||||
|
||||
Reference in New Issue
Block a user