Replace Logger with DI::logger() in Object classes

This commit is contained in:
Art4 2025-01-13 12:01:48 +00:00
parent 0b20a9c923
commit 33b5ba35d4
2 changed files with 12 additions and 14 deletions

View file

@ -11,7 +11,6 @@ use Friendica\Content\ContactSelector;
use Friendica\Content\Feature; use Friendica\Content\Feature;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
@ -782,10 +781,10 @@ class Post
public function addChild(Post $item) public function addChild(Post $item)
{ {
if (!$item->getId()) { if (!$item->getId()) {
Logger::error('Post object has no id', ['post' => $item]); DI::logger()->error('Post object has no id', ['post' => $item]);
return false; return false;
} elseif ($this->getChild($item->getId())) { } elseif ($this->getChild($item->getId())) {
Logger::warning('Post object already exists', ['post' => $item]); DI::logger()->warning('Post object already exists', ['post' => $item]);
return false; return false;
} }
@ -793,13 +792,13 @@ class Post
* Only add what will be displayed * Only add what will be displayed
*/ */
if ($item->getDataValue('network') === Protocol::MAIL && DI::userSession()->getLocalUserId() != $item->getDataValue('uid')) { if ($item->getDataValue('network') === Protocol::MAIL && DI::userSession()->getLocalUserId() != $item->getDataValue('uid')) {
Logger::warning('Post object does not belong to local user', ['post' => $item, 'local_user' => DI::userSession()->getLocalUserId()]); DI::logger()->warning('Post object does not belong to local user', ['post' => $item, 'local_user' => DI::userSession()->getLocalUserId()]);
return false; return false;
} elseif ( } elseif (
DI::activity()->match($item->getDataValue('verb'), Activity::LIKE) || DI::activity()->match($item->getDataValue('verb'), Activity::LIKE) ||
DI::activity()->match($item->getDataValue('verb'), Activity::DISLIKE) DI::activity()->match($item->getDataValue('verb'), Activity::DISLIKE)
) { ) {
Logger::warning('Post objects is a like/dislike', ['post' => $item]); DI::logger()->warning('Post objects is a like/dislike', ['post' => $item]);
return false; return false;
} }
@ -884,7 +883,7 @@ class Post
} }
} }
Logger::info('[WARN] Item::removeChild : Item is not a child (' . $id . ').'); DI::logger()->info('[WARN] Item::removeChild : Item is not a child (' . $id . ').');
return false; return false;
} }
@ -947,7 +946,7 @@ class Post
public function getDataValue(string $name) public function getDataValue(string $name)
{ {
if (!isset($this->data[$name])) { if (!isset($this->data[$name])) {
// Logger::info('[ERROR] Item::getDataValue : Item has no value name "'. $name .'".'); // DI::logger()->info('[ERROR] Item::getDataValue : Item has no value name "'. $name .'".');
return false; return false;
} }

View file

@ -8,7 +8,6 @@
namespace Friendica\Object; namespace Friendica\Object;
use Friendica\Content\Conversation; use Friendica\Content\Conversation;
use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\DI; use Friendica\DI;
use Friendica\Protocol\Activity; use Friendica\Protocol\Activity;
@ -77,7 +76,7 @@ class Thread
$this->writable = $writable; $this->writable = $writable;
break; break;
default: default:
Logger::info('[ERROR] Conversation::setMode : Unhandled mode ('. $mode .').'); DI::logger()->info('[ERROR] Conversation::setMode : Unhandled mode ('. $mode .').');
return false; return false;
break; break;
} }
@ -138,12 +137,12 @@ class Thread
$item_id = $item->getId(); $item_id = $item->getId();
if (!$item_id) { if (!$item_id) {
Logger::info('[ERROR] Conversation::addThread : Item has no ID!!'); DI::logger()->info('[ERROR] Conversation::addThread : Item has no ID!!');
return false; return false;
} }
if ($this->getParent($item->getId())) { if ($this->getParent($item->getId())) {
Logger::info('[WARN] Conversation::addThread : Thread already exists ('. $item->getId() .').'); DI::logger()->info('[WARN] Conversation::addThread : Thread already exists ('. $item->getId() .').');
return false; return false;
} }
@ -151,12 +150,12 @@ class Thread
* Only add will be displayed * Only add will be displayed
*/ */
if ($item->getDataValue('network') === Protocol::MAIL && DI::userSession()->getLocalUserId() != $item->getDataValue('uid')) { if ($item->getDataValue('network') === Protocol::MAIL && DI::userSession()->getLocalUserId() != $item->getDataValue('uid')) {
Logger::info('[WARN] Conversation::addThread : Thread is a mail ('. $item->getId() .').'); DI::logger()->info('[WARN] Conversation::addThread : Thread is a mail ('. $item->getId() .').');
return false; return false;
} }
if ($item->getDataValue('verb') === Activity::LIKE || $item->getDataValue('verb') === Activity::DISLIKE) { if ($item->getDataValue('verb') === Activity::LIKE || $item->getDataValue('verb') === Activity::DISLIKE) {
Logger::info('[WARN] Conversation::addThread : Thread is a (dis)like ('. $item->getId() .').'); DI::logger()->info('[WARN] Conversation::addThread : Thread is a (dis)like ('. $item->getId() .').');
return false; return false;
} }
@ -190,7 +189,7 @@ class Thread
$item_data = $item->getTemplateData($conv_responses, $formSecurityToken); $item_data = $item->getTemplateData($conv_responses, $formSecurityToken);
if (!$item_data) { if (!$item_data) {
Logger::info('[ERROR] Conversation::getTemplateData : Failed to get item template data ('. $item->getId() .').'); DI::logger()->info('[ERROR] Conversation::getTemplateData : Failed to get item template data ('. $item->getId() .').');
return false; return false;
} }
$result[] = $item_data; $result[] = $item_data;