Skip to content

Commit 2a0cb8d

Browse files
committed
refactor(federation): omit app argument for error messages
As federation is an app, the LoggerInterface instance is ScopedPsrLogger and will set it. Signed-off-by: Daniel Kesselberg <[email protected]>
1 parent 3fa81d0 commit 2a0cb8d

File tree

5 files changed

+11
-16
lines changed

5 files changed

+11
-16
lines changed

apps/federation/lib/BackgroundJob/GetSharedSecret.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ protected function run($argument) {
115115
} catch (ClientException $e) {
116116
$status = $e->getCode();
117117
if ($status === Http::STATUS_FORBIDDEN) {
118-
$this->logger->info($target . ' refused to exchange a shared secret with you.', ['app' => 'federation']);
118+
$this->logger->info($target . ' refused to exchange a shared secret with you.');
119119
} else {
120-
$this->logger->info($target . ' responded with a ' . $status . ' containing: ' . $e->getMessage(), ['app' => 'federation']);
120+
$this->logger->info($target . ' responded with a ' . $status . ' containing: ' . $e->getMessage());
121121
}
122122
} catch (RequestException $e) {
123123
$status = -1; // There is no status code if we could not connect
@@ -149,8 +149,7 @@ protected function run($argument) {
149149
);
150150
} else {
151151
$this->logger->error(
152-
'remote server "' . $target . '"" does not return a valid shared secret. Received data: ' . $body,
153-
['app' => 'federation']
152+
'remote server "' . $target . '"" does not return a valid shared secret. Received data: ' . $body
154153
);
155154
$this->trustedServers->setServerStatus($target, TrustedServers::STATUS_FAILURE);
156155
}

apps/federation/lib/BackgroundJob/RequestSharedSecret.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,16 @@ protected function run($argument) {
126126
} catch (ClientException $e) {
127127
$status = $e->getCode();
128128
if ($status === Http::STATUS_FORBIDDEN) {
129-
$this->logger->info($target . ' refused to ask for a shared secret.', ['app' => 'federation']);
129+
$this->logger->info($target . ' refused to ask for a shared secret.');
130130
} else {
131-
$this->logger->info($target . ' responded with a ' . $status . ' containing: ' . $e->getMessage(), ['app' => 'federation']);
131+
$this->logger->info($target . ' responded with a ' . $status . ' containing: ' . $e->getMessage());
132132
}
133133
} catch (RequestException $e) {
134134
$status = -1; // There is no status code if we could not connect
135-
$this->logger->info('Could not connect to ' . $target, ['app' => 'federation']);
135+
$this->logger->info('Could not connect to ' . $target);
136136
} catch (\Throwable $e) {
137137
$status = Http::STATUS_INTERNAL_SERVER_ERROR;
138-
$this->logger->error($e->getMessage(), ['app' => 'federation', 'exception' => $e]);
138+
$this->logger->error($e->getMessage(), ['exception' => $e]);
139139
}
140140

141141
// if we received a unexpected response we try again later

apps/federation/lib/Controller/OCSAuthAPIController.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function getSharedSecretLegacy(string $url, string $token): DataResponse
9898
public function requestSharedSecret(string $url, string $token): DataResponse {
9999
if ($this->trustedServers->isTrustedServer($url) === false) {
100100
$this->throttler->registerAttempt('federationSharedSecret', $this->request->getRemoteAddress());
101-
$this->logger->error('remote server not trusted (' . $url . ') while requesting shared secret', ['app' => 'federation']);
101+
$this->logger->error('remote server not trusted (' . $url . ') while requesting shared secret');
102102
throw new OCSForbiddenException();
103103
}
104104

@@ -107,8 +107,7 @@ public function requestSharedSecret(string $url, string $token): DataResponse {
107107
$localToken = $this->dbHandler->getToken($url);
108108
if (strcmp($localToken, $token) > 0) {
109109
$this->logger->info(
110-
'remote server (' . $url . ') presented lower token. We will initiate the exchange of the shared secret.',
111-
['app' => 'federation']
110+
'remote server (' . $url . ') presented lower token. We will initiate the exchange of the shared secret.'
112111
);
113112
throw new OCSForbiddenException();
114113
}
@@ -141,16 +140,15 @@ public function requestSharedSecret(string $url, string $token): DataResponse {
141140
public function getSharedSecret(string $url, string $token): DataResponse {
142141
if ($this->trustedServers->isTrustedServer($url) === false) {
143142
$this->throttler->registerAttempt('federationSharedSecret', $this->request->getRemoteAddress());
144-
$this->logger->error('remote server not trusted (' . $url . ') while getting shared secret', ['app' => 'federation']);
143+
$this->logger->error('remote server not trusted (' . $url . ') while getting shared secret');
145144
throw new OCSForbiddenException();
146145
}
147146

148147
if ($this->isValidToken($url, $token) === false) {
149148
$this->throttler->registerAttempt('federationSharedSecret', $this->request->getRemoteAddress());
150149
$expectedToken = $this->dbHandler->getToken($url);
151150
$this->logger->error(
152-
'remote server (' . $url . ') didn\'t send a valid token (got "' . $token . '" but expected "' . $expectedToken . '") while getting shared secret',
153-
['app' => 'federation']
151+
'remote server (' . $url . ') didn\'t send a valid token (got "' . $token . '" but expected "' . $expectedToken . '") while getting shared secret'
154152
);
155153
throw new OCSForbiddenException();
156154
}

apps/federation/lib/SyncJob.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ protected function run($argument) {
2727
$this->syncService->syncThemAll(function ($url, $ex): void {
2828
if ($ex instanceof \Exception) {
2929
$this->logger->error("Error while syncing $url.", [
30-
'app' => 'fed-sync',
3130
'exception' => $ex,
3231
]);
3332
}

apps/federation/lib/TrustedServers.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ public function isNextcloudServer(string $url): bool {
169169
}
170170
} catch (\Exception $e) {
171171
$this->logger->error('No Nextcloud server.', [
172-
'app' => 'federation',
173172
'exception' => $e,
174173
]);
175174
return false;

0 commit comments

Comments
 (0)