summaryrefslogtreecommitdiffstats
path: root/apps/federation
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-01-17 15:21:56 +0100
committerMorris Jobke <hey@morrisjobke.de>2018-01-23 10:57:21 +0100
commit2a38605545e26ce68a37e5ebb877fd9c9875a37d (patch)
treea149433f3fdeae3b4615061b495e4c523328a9a6 /apps/federation
parent520f2fd6ea3661d5d49517c7265dd8d7515036ac (diff)
downloadnextcloud-server-2a38605545e26ce68a37e5ebb877fd9c9875a37d.tar.gz
nextcloud-server-2a38605545e26ce68a37e5ebb877fd9c9875a37d.zip
Properly log the full exception instead of only the message
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/federation')
-rw-r--r--apps/federation/lib/BackgroundJob/GetSharedSecret.php12
-rw-r--r--apps/federation/lib/Middleware/AddServerMiddleware.php5
-rw-r--r--apps/federation/lib/SyncJob.php6
-rw-r--r--apps/federation/lib/TrustedServers.php6
-rw-r--r--apps/federation/tests/Middleware/AddServerMiddlewareTest.php10
5 files changed, 28 insertions, 11 deletions
diff --git a/apps/federation/lib/BackgroundJob/GetSharedSecret.php b/apps/federation/lib/BackgroundJob/GetSharedSecret.php
index 92bb31e369e..829e04ddb28 100644
--- a/apps/federation/lib/BackgroundJob/GetSharedSecret.php
+++ b/apps/federation/lib/BackgroundJob/GetSharedSecret.php
@@ -201,10 +201,18 @@ class GetSharedSecret extends Job {
}
} catch (RequestException $e) {
$status = -1; // There is no status code if we could not connect
- $this->logger->info('Could not connect to ' . $target, ['app' => 'federation']);
+ $this->logger->logException($e, [
+ 'message' => 'Could not connect to ' . $target,
+ 'level' => \OCP\Util::INFO,
+ 'app' => 'federation',
+ ]);
} catch (RingException $e) {
$status = -1; // There is no status code if we could not connect
- $this->logger->info('Could not connect to ' . $target, ['app' => 'federation']);
+ $this->logger->logException($e, [
+ 'message' => 'Could not connect to ' . $target,
+ 'level' => \OCP\Util::INFO,
+ 'app' => 'federation',
+ ]);
} catch (\Exception $e) {
$status = Http::STATUS_INTERNAL_SERVER_ERROR;
$this->logger->logException($e, ['app' => 'federation']);
diff --git a/apps/federation/lib/Middleware/AddServerMiddleware.php b/apps/federation/lib/Middleware/AddServerMiddleware.php
index 247cc958833..c6ac42bd7c3 100644
--- a/apps/federation/lib/Middleware/AddServerMiddleware.php
+++ b/apps/federation/lib/Middleware/AddServerMiddleware.php
@@ -71,7 +71,10 @@ class AddServerMiddleware extends Middleware {
if (($controller instanceof SettingsController) === false) {
throw $exception;
}
- $this->logger->error($exception->getMessage(), ['app' => $this->appName]);
+ $this->logger->logException($exception, [
+ 'level' => \OCP\Util::ERROR,
+ 'app' => $this->appName,
+ ]);
if ($exception instanceof HintException) {
$message = $exception->getHint();
} else {
diff --git a/apps/federation/lib/SyncJob.php b/apps/federation/lib/SyncJob.php
index 0aa1d61affb..23255f2a441 100644
--- a/apps/federation/lib/SyncJob.php
+++ b/apps/federation/lib/SyncJob.php
@@ -49,7 +49,11 @@ class SyncJob extends TimedJob {
protected function run($argument) {
$this->syncService->syncThemAll(function($url, $ex) {
if ($ex instanceof \Exception) {
- $this->logger->error("Error while syncing $url : " . $ex->getMessage(), ['app' => 'fed-sync']);
+ $this->logger->logException($ex, [
+ 'message' => "Error while syncing $url.",
+ 'level' => \OCP\Util::ERROR,
+ 'app' => 'fed-sync',
+ ]);
}
});
}
diff --git a/apps/federation/lib/TrustedServers.php b/apps/federation/lib/TrustedServers.php
index 79cf86ab67b..2067533c3e7 100644
--- a/apps/federation/lib/TrustedServers.php
+++ b/apps/federation/lib/TrustedServers.php
@@ -241,7 +241,11 @@ class TrustedServers {
}
} catch (\Exception $e) {
- $this->logger->debug('No Nextcloud server: ' . $e->getMessage());
+ \OC::$server->getLogger()->logException($e, [
+ 'message' => 'No Nextcloud server.',
+ 'level' => \OCP\Util::DEBUG,
+ 'app' => 'federation',
+ ]);
return false;
}
diff --git a/apps/federation/tests/Middleware/AddServerMiddlewareTest.php b/apps/federation/tests/Middleware/AddServerMiddlewareTest.php
index 4620234d685..7bae5e566fc 100644
--- a/apps/federation/tests/Middleware/AddServerMiddlewareTest.php
+++ b/apps/federation/tests/Middleware/AddServerMiddlewareTest.php
@@ -68,13 +68,11 @@ class AddServerMiddlewareTest extends TestCase {
* @dataProvider dataTestAfterException
*
* @param \Exception $exception
- * @param string $message
* @param string $hint
*/
- public function testAfterException($exception, $message, $hint) {
+ public function testAfterException($exception, $hint) {
- $this->logger->expects($this->once())->method('error')
- ->with($message, ['app' => 'AddServerMiddlewareTest']);
+ $this->logger->expects($this->once())->method('logException');
$this->l10n->expects($this->any())->method('t')
->willReturnCallback(
@@ -98,8 +96,8 @@ class AddServerMiddlewareTest extends TestCase {
public function dataTestAfterException() {
return [
- [new HintException('message', 'hint'), 'message', 'hint'],
- [new \Exception('message'), 'message', 'message'],
+ [new HintException('message', 'hint'), 'hint'],
+ [new \Exception('message'), 'message'],
];
}