diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-05-09 14:06:44 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-05-09 14:06:44 +0200 |
commit | d3a244f9d9f3a90b7bd92a22210601c7f543441f (patch) | |
tree | 414cd462f3aa50801f0e7be515e73add464237d5 /lib/private/Support/CrashReport | |
parent | 35b31110efce6799b1926c9485a246a1c60782dd (diff) | |
download | nextcloud-server-d3a244f9d9f3a90b7bd92a22210601c7f543441f.tar.gz nextcloud-server-d3a244f9d9f3a90b7bd92a22210601c7f543441f.zip |
Allow crash reporters to catpture any message
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/private/Support/CrashReport')
-rw-r--r-- | lib/private/Support/CrashReport/Registry.php | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/private/Support/CrashReport/Registry.php b/lib/private/Support/CrashReport/Registry.php index 72c43fe37e2..be022efb385 100644 --- a/lib/private/Support/CrashReport/Registry.php +++ b/lib/private/Support/CrashReport/Registry.php @@ -24,6 +24,7 @@ namespace OC\Support\CrashReport; use Exception; use OCP\Support\CrashReport\ICollectBreadcrumbs; +use OCP\Support\CrashReport\IMessageReporter; use OCP\Support\CrashReport\IRegistry; use OCP\Support\CrashReport\IReporter; use Throwable; @@ -38,7 +39,7 @@ class Registry implements IRegistry { * * @param IReporter $reporter */ - public function register(IReporter $reporter) { + public function register(IReporter $reporter): void { $this->reporters[] = $reporter; } @@ -51,7 +52,7 @@ class Registry implements IRegistry { * * @since 15.0.0 */ - public function delegateBreadcrumb(string $message, string $category, array $context = []) { + public function delegateBreadcrumb(string $message, string $category, array $context = []): void { foreach ($this->reporters as $reporter) { if ($reporter instanceof ICollectBreadcrumbs) { $reporter->collect($message, $category, $context); @@ -65,11 +66,27 @@ class Registry implements IRegistry { * @param Exception|Throwable $exception * @param array $context */ - public function delegateReport($exception, array $context = []) { + public function delegateReport($exception, array $context = []): void { /** @var IReporter $reporter */ foreach ($this->reporters as $reporter) { $reporter->report($exception, $context); } } + /** + * Delegate a message to all reporters that implement IMessageReporter + * + * @param string $message + * @param array $context + * + * @return void + */ + public function delegateMessage(string $message, array $context = []): void { + foreach ($this->reporters as $reporter) { + if ($reporter instanceof IMessageReporter) { + $reporter->reportMessage($message, $context); + } + } + } + } |