diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-01-17 15:21:56 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2018-01-23 10:57:21 +0100 |
commit | 2a38605545e26ce68a37e5ebb877fd9c9875a37d (patch) | |
tree | a149433f3fdeae3b4615061b495e4c523328a9a6 /apps/files_external/lib | |
parent | 520f2fd6ea3661d5d49517c7265dd8d7515036ac (diff) | |
download | nextcloud-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/files_external/lib')
-rw-r--r-- | apps/files_external/lib/Lib/Storage/Swift.php | 45 | ||||
-rw-r--r-- | apps/files_external/lib/Service/LegacyStoragesService.php | 10 | ||||
-rw-r--r-- | apps/files_external/lib/Service/StoragesService.php | 29 |
3 files changed, 55 insertions, 29 deletions
diff --git a/apps/files_external/lib/Lib/Storage/Swift.php b/apps/files_external/lib/Lib/Storage/Swift.php index f07087e903d..aeedd3dcd63 100644 --- a/apps/files_external/lib/Lib/Storage/Swift.php +++ b/apps/files_external/lib/Lib/Storage/Swift.php @@ -138,7 +138,10 @@ class Swift extends \OC\Files\Storage\Common { } catch (ClientErrorResponseException $e) { // Expected response is "404 Not Found", so only log if it isn't if ($e->getResponse()->getStatusCode() !== 404) { - \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR); + \OC::$server->getLogger()->logException($e, [ + 'level' => \OCP\Util::ERROR, + 'app' => 'files_external', + ]); } return false; } @@ -206,7 +209,10 @@ class Swift extends \OC\Files\Storage\Common { // with all properties $this->objectCache->remove($path); } catch (Exceptions\CreateUpdateError $e) { - \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR); + \OC::$server->getLogger()->logException($e, [ + 'level' => \OCP\Util::ERROR, + 'app' => 'files_external', + ]); return false; } @@ -247,7 +253,10 @@ class Swift extends \OC\Files\Storage\Common { $this->getContainer()->dataObject()->setName($path . '/')->delete(); $this->objectCache->remove($path . '/'); } catch (Exceptions\DeleteError $e) { - \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR); + \OC::$server->getLogger()->logException($e, [ + 'level' => \OCP\Util::ERROR, + 'app' => 'files_external', + ]); return false; } @@ -283,7 +292,10 @@ class Swift extends \OC\Files\Storage\Common { return IteratorDirectory::wrap($files); } catch (\Exception $e) { - \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR); + \OC::$server->getLogger()->logException($e, [ + 'level' => \OCP\Util::ERROR, + 'app' => 'files_external', + ]); return false; } @@ -305,7 +317,10 @@ class Swift extends \OC\Files\Storage\Common { return false; } } catch (ClientErrorResponseException $e) { - \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR); + \OC::$server->getLogger()->logException($e, [ + 'level' => \OCP\Util::ERROR, + 'app' => 'files_external', + ]); return false; } @@ -361,7 +376,10 @@ class Swift extends \OC\Files\Storage\Common { $this->objectCache->remove($path . '/'); } catch (ClientErrorResponseException $e) { if ($e->getResponse()->getStatusCode() !== 404) { - \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR); + \OC::$server->getLogger()->logException($e, [ + 'level' => \OCP\Util::ERROR, + 'app' => 'files_external', + ]); } return false; } @@ -394,7 +412,10 @@ class Swift extends \OC\Files\Storage\Common { } return false; } catch (\Guzzle\Http\Exception\BadResponseException $e) { - \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR); + \OC::$server->getLogger()->logException($e, [ + 'level' => \OCP\Util::ERROR, + 'app' => 'files_external', + ]); return false; } case 'w': @@ -474,7 +495,10 @@ class Swift extends \OC\Files\Storage\Common { $this->objectCache->remove($path2); $this->objectCache->remove($path2 . '/'); } catch (ClientErrorResponseException $e) { - \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR); + \OC::$server->getLogger()->logException($e, [ + 'level' => \OCP\Util::ERROR, + 'app' => 'files_external', + ]); return false; } @@ -490,7 +514,10 @@ class Swift extends \OC\Files\Storage\Common { $this->objectCache->remove($path2); $this->objectCache->remove($path2 . '/'); } catch (ClientErrorResponseException $e) { - \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR); + \OC::$server->getLogger()->logException($e, [ + 'level' => \OCP\Util::ERROR, + 'app' => 'files_external', + ]); return false; } diff --git a/apps/files_external/lib/Service/LegacyStoragesService.php b/apps/files_external/lib/Service/LegacyStoragesService.php index 68faf0f2854..65880514911 100644 --- a/apps/files_external/lib/Service/LegacyStoragesService.php +++ b/apps/files_external/lib/Service/LegacyStoragesService.php @@ -192,11 +192,11 @@ abstract class LegacyStoragesService { } } catch (\UnexpectedValueException $e) { // don't die if a storage backend doesn't exist - \OCP\Util::writeLog( - 'files_external', - 'Could not load storage: "' . $e->getMessage() . '"', - \OCP\Util::ERROR - ); + \OC::$server->getLogger()->logException($e, [ + 'message' => 'Could not load storage.', + 'level' => \OCP\Util::ERROR, + 'app' => 'files_external', + ]); } } } diff --git a/apps/files_external/lib/Service/StoragesService.php b/apps/files_external/lib/Service/StoragesService.php index d52bf410461..89458b70c0c 100644 --- a/apps/files_external/lib/Service/StoragesService.php +++ b/apps/files_external/lib/Service/StoragesService.php @@ -102,18 +102,18 @@ abstract class StoragesService { return $config; } catch (\UnexpectedValueException $e) { // don't die if a storage backend doesn't exist - \OCP\Util::writeLog( - 'files_external', - 'Could not load storage: "' . $e->getMessage() . '"', - \OCP\Util::ERROR - ); + \OC::$server->getLogger()->logException($e, [ + 'message' => 'Could not load storage.', + 'level' => \OCP\Util::ERROR, + 'app' => 'files_external', + ]); return null; } catch (\InvalidArgumentException $e) { - \OCP\Util::writeLog( - 'files_external', - 'Could not load storage: "' . $e->getMessage() . '"', - \OCP\Util::ERROR - ); + \OC::$server->getLogger()->logException($e, [ + 'message' => 'Could not load storage.', + 'level' => \OCP\Util::ERROR, + 'app' => 'files_external', + ]); return null; } } @@ -478,11 +478,10 @@ abstract class StoragesService { // can happen either for invalid configs where the storage could not // be instantiated or whenever $user vars where used, in which case // the storage id could not be computed - \OCP\Util::writeLog( - 'files_external', - 'Exception: "' . $e->getMessage() . '"', - \OCP\Util::ERROR - ); + \OC::$server->getLogger()->logException($e, [ + 'level' => \OCP\Util::ERROR, + 'app' => 'files_external', + ]); } } |