Pass the exception context to the crash reporter
This should allow better reports as often the app id is passed as context. While this is not used right now, I'd like to have this for NC13 as adding it later will break the interface for existing apps Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
parent
2a39ac043e
commit
ad757805ca
|
@ -352,7 +352,7 @@ class Log implements ILogger {
|
||||||
$msg .= ': ' . json_encode($data);
|
$msg .= ': ' . json_encode($data);
|
||||||
$this->log($level, $msg, $context);
|
$this->log($level, $msg, $context);
|
||||||
if (!is_null($this->crashReporters)) {
|
if (!is_null($this->crashReporters)) {
|
||||||
$this->crashReporters->delegateReport($exception);
|
$this->crashReporters->delegateReport($exception, $context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,10 +45,11 @@ class Registry implements IRegistry {
|
||||||
* Delegate crash reporting to all registered reporters
|
* Delegate crash reporting to all registered reporters
|
||||||
*
|
*
|
||||||
* @param Exception|Throwable $exception
|
* @param Exception|Throwable $exception
|
||||||
|
* @param array $context
|
||||||
*/
|
*/
|
||||||
public function delegateReport($exception) {
|
public function delegateReport($exception, array $context = []) {
|
||||||
foreach ($this->reporters as $reporter) {
|
foreach ($this->reporters as $reporter) {
|
||||||
$reporter->report($exception);
|
$reporter->report($exception, $context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ interface IRegistry {
|
||||||
*
|
*
|
||||||
* @since 13.0.0
|
* @since 13.0.0
|
||||||
* @param Exception|Throwable $exception
|
* @param Exception|Throwable $exception
|
||||||
|
* @param array $context
|
||||||
*/
|
*/
|
||||||
public function delegateReport($exception);
|
public function delegateReport($exception, array $context = []);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ interface IReporter {
|
||||||
*
|
*
|
||||||
* @since 13.0.0
|
* @since 13.0.0
|
||||||
* @param Exception|Throwable $exception
|
* @param Exception|Throwable $exception
|
||||||
|
* @param array $context
|
||||||
*/
|
*/
|
||||||
public function report($exception);
|
public function report($exception, array $context = []);
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ class LoggerTest extends TestCase {
|
||||||
$e = new \Exception('test');
|
$e = new \Exception('test');
|
||||||
$this->registry->expects($this->once())
|
$this->registry->expects($this->once())
|
||||||
->method('delegateReport')
|
->method('delegateReport')
|
||||||
->with($e);
|
->with($e, []);
|
||||||
|
|
||||||
$this->logger->logException($e);
|
$this->logger->logException($e);
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ class LoggerTest extends TestCase {
|
||||||
$e = new \Exception('test');
|
$e = new \Exception('test');
|
||||||
$this->registry->expects($this->once())
|
$this->registry->expects($this->once())
|
||||||
->method('delegateReport')
|
->method('delegateReport')
|
||||||
->with($e);
|
->with($e, []);
|
||||||
|
|
||||||
$this->logger->logException($e);
|
$this->logger->logException($e);
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ class LoggerTest extends TestCase {
|
||||||
$e = new \Exception('test');
|
$e = new \Exception('test');
|
||||||
$this->registry->expects($this->once())
|
$this->registry->expects($this->once())
|
||||||
->method('delegateReport')
|
->method('delegateReport')
|
||||||
->with($e);
|
->with($e, []);
|
||||||
|
|
||||||
$this->logger->logException($e);
|
$this->logger->logException($e);
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ class LoggerTest extends TestCase {
|
||||||
$e = new \Exception('test');
|
$e = new \Exception('test');
|
||||||
$this->registry->expects($this->once())
|
$this->registry->expects($this->once())
|
||||||
->method('delegateReport')
|
->method('delegateReport')
|
||||||
->with($e);
|
->with($e, []);
|
||||||
|
|
||||||
$this->logger->logException($e);
|
$this->logger->logException($e);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue