Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce log messages by account auto detect #6488

Merged
merged 1 commit into from May 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Reduce log messages by account auto detect
Account auto detect produce a lot of log messages spamming the log file. This pr will reduce the verbosity of the logged information

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
  • Loading branch information
kesselb committed May 17, 2022
commit ab9ade57fbc1f465ffe905248f93f328d638d7e5
11 changes: 5 additions & 6 deletions lib/Controller/AccountsController.php
Expand Up @@ -336,7 +336,6 @@ public function destroy(int $id): JSONResponse {
* @param bool $autoDetect
*
* @return JSONResponse
* @throws ClientException
*/
public function create(string $accountName, string $emailAddress, string $password = null, string $imapHost = null, int $imapPort = null, string $imapSslMode = null, string $imapUser = null, string $imapPassword = null, string $smtpHost = null, int $smtpPort = null, string $smtpSslMode = null, string $smtpUser = null, string $smtpPassword = null, bool $autoDetect = true): JSONResponse {
try {
Expand All @@ -346,15 +345,15 @@ public function create(string $accountName, string $emailAddress, string $passwo
$account = $this->setup->createNewAccount($accountName, $emailAddress, $imapHost, $imapPort, $imapSslMode, $imapUser, $imapPassword, $smtpHost, $smtpPort, $smtpSslMode, $smtpUser, $smtpPassword, $this->currentUserId);
}
} catch (CouldNotConnectException $e) {
$this->logger->info('Creating account failed: ' . $e->getMessage(), [
'exception' => $e,
]);
return \OCA\Mail\Http\JsonResponse::fail([
$data = [
'error' => $e->getReason(),
'service' => $e->getService(),
'host' => $e->getHost(),
'port' => $e->getPort(),
]);
];

$this->logger->info('Creating account failed: ' . $e->getMessage(), $data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's hope there will never be a conflict between $data and the generated json array :P

return \OCA\Mail\Http\JsonResponse::fail($data);
} catch (ServiceException $e) {
$this->logger->error('Creating account failed: ' . $e->getMessage(), [
'exception' => $e,
Expand Down