diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2019-10-03 20:11:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-03 20:11:13 +0300 |
commit | b5504ef2b3a2e238c40ee190538822624aa638a7 (patch) | |
tree | 133e981efafa72063a4140bdf8d3ff7ef1a2f93a | |
parent | 4a4392a4f88757aa172d5ff5a72cfd32b3d5838e (diff) | |
parent | 50474235627beae7a4741a1a6f08ed36fb040bf7 (diff) |
Merge pull request #134 from nextcloud/fix/log/no-user
Fix/log/no user
-rw-r--r-- | lib/Item.php | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/Item.php b/lib/Item.php index 7cf9391..b093541 100644 --- a/lib/Item.php +++ b/lib/Item.php @@ -194,24 +194,33 @@ class Item { } } + private function generateExtraInfo() { + $owner = $this->file->getOwner(); + + if ($owner === null) { + $ownerInfo = 'Account: NO OWNER FOUND'; + } else { + $ownerInfo = 'Account: ' . $owner->getUID(); + } + + $extra = ' File: ' . $this->file->getId() + . $ownerInfo + . ' Path: ' . $this->file->getPath(); + + return $extra; + } + /** * @param string $message */ public function logDebug($message) { - $extra = ' File: ' . $this->file->getId() - . ' Account: ' . $this->file->getOwner()->getUID() - . ' Path: ' . $this->file->getPath(); - $this->logger->debug($message . $extra, ['app' => 'files_antivirus']); + $this->logger->debug($message . $this->generateExtraInfo(), ['app' => 'files_antivirus']); } /** * @param string $message */ public function logError($message) { - $ownerInfo = 'Account: ' . $this->file->getOwner()->getUID(); - $extra = ' File: ' . $this->file->getId() - . $ownerInfo - . ' Path: ' . $this->file->getPath(); - $this->logger->error($message . $extra, ['app' => 'files_antivirus']); + $this->logger->error($message . $this->generateExtraInfo(), ['app' => 'files_antivirus']); } } |