Browse Source

Merge pull request #7166 from nextcloud/enhancement/crash-report-context

Pass the exception context to the crash reporter
pull/7167/head
Morris Jobke 8 years ago
committed by GitHub
parent
commit
16549ae5fb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      lib/private/Log.php
  2. 6
      lib/private/Support/CrashReport/Registry.php
  3. 3
      lib/public/Support/CrashReport/IRegistry.php
  4. 3
      lib/public/Support/CrashReport/IReporter.php
  5. 8
      tests/lib/LoggerTest.php

2
lib/private/Log.php

@ -352,7 +352,7 @@ class Log implements ILogger {
$msg .= ': ' . json_encode($data);
$this->log($level, $msg, $context);
if (!is_null($this->crashReporters)) {
$this->crashReporters->delegateReport($exception);
$this->crashReporters->delegateReport($exception, $context);
}
}

6
lib/private/Support/CrashReport/Registry.php

@ -45,10 +45,12 @@ class Registry implements IRegistry {
* Delegate crash reporting to all registered reporters
*
* @param Exception|Throwable $exception
* @param array $context
*/
public function delegateReport($exception) {
public function delegateReport($exception, array $context = []) {
/** @var IReporter $reporter */
foreach ($this->reporters as $reporter) {
$reporter->report($exception);
$reporter->report($exception, $context);
}
}

3
lib/public/Support/CrashReport/IRegistry.php

@ -43,6 +43,7 @@ interface IRegistry {
*
* @since 13.0.0
* @param Exception|Throwable $exception
* @param array $context
*/
public function delegateReport($exception);
public function delegateReport($exception, array $context = []);
}

3
lib/public/Support/CrashReport/IReporter.php

@ -35,6 +35,7 @@ interface IReporter {
*
* @since 13.0.0
* @param Exception|Throwable $exception
* @param array $context
*/
public function report($exception);
public function report($exception, array $context = []);
}

8
tests/lib/LoggerTest.php

@ -90,7 +90,7 @@ class LoggerTest extends TestCase {
$e = new \Exception('test');
$this->registry->expects($this->once())
->method('delegateReport')
->with($e);
->with($e, []);
$this->logger->logException($e);
@ -109,7 +109,7 @@ class LoggerTest extends TestCase {
$e = new \Exception('test');
$this->registry->expects($this->once())
->method('delegateReport')
->with($e);
->with($e, []);
$this->logger->logException($e);
@ -128,7 +128,7 @@ class LoggerTest extends TestCase {
$e = new \Exception('test');
$this->registry->expects($this->once())
->method('delegateReport')
->with($e);
->with($e, []);
$this->logger->logException($e);
@ -147,7 +147,7 @@ class LoggerTest extends TestCase {
$e = new \Exception('test');
$this->registry->expects($this->once())
->method('delegateReport')
->with($e);
->with($e, []);
$this->logger->logException($e);

Loading…
Cancel
Save