From 8fe3383976a60ec4cf53ad8f020b78da2125512a Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 13 Jan 2025 13:19:24 +0000 Subject: [PATCH] Replace Logger with DI::logger() in many Worker classes --- src/Worker/APDelivery.php | 6 +++--- src/Worker/BulkDelivery.php | 5 ++--- src/Worker/CheckRelMeProfileLink.php | 17 ++++++++--------- src/Worker/CheckVersion.php | 9 ++++----- src/Worker/Cron.php | 9 ++++----- src/Worker/DelayedPublish.php | 4 ++-- src/Worker/Directory.php | 3 +-- src/Worker/FetchFeaturedPosts.php | 6 +++--- src/Worker/FetchMissingActivity.php | 13 ++++++------- src/Worker/MergeContact.php | 4 ++-- src/Worker/NodeInfo.php | 9 ++++----- src/Worker/OptimizeTables.php | 7 +++---- src/Worker/PollContacts.php | 5 ++--- src/Worker/ProfileUpdate.php | 3 +-- src/Worker/PullDirectory.php | 13 ++++++------- src/Worker/PushSubscription.php | 17 ++++++++--------- src/Worker/SearchDirectory.php | 5 ++--- src/Worker/SetSeen.php | 4 ++-- src/Worker/SpoolPost.php | 14 +++++++------- 19 files changed, 70 insertions(+), 83 deletions(-) diff --git a/src/Worker/APDelivery.php b/src/Worker/APDelivery.php index a3966de8c4..2d1df8cca4 100644 --- a/src/Worker/APDelivery.php +++ b/src/Worker/APDelivery.php @@ -7,8 +7,8 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; use Friendica\Core\Worker; +use Friendica\DI; use Friendica\Model\Post; use Friendica\Model\User; use Friendica\Protocol\ActivityPub; @@ -29,7 +29,7 @@ class APDelivery public static function execute(string $cmd, int $item_id, string $inbox, int $uid, array $receivers = [], int $uri_id = 0) { if (ActivityPub\Transmitter::archivedInbox($inbox)) { - Logger::info('Inbox is archived', ['cmd' => $cmd, 'inbox' => $inbox, 'id' => $item_id, 'uri-id' => $uri_id, 'uid' => $uid]); + DI::logger()->info('Inbox is archived', ['cmd' => $cmd, 'inbox' => $inbox, 'id' => $item_id, 'uri-id' => $uri_id, 'uid' => $uid]); if (empty($uri_id) && !empty($item_id)) { $item = Post::selectFirst(['uri-id'], ['id' => $item_id]); $uri_id = $item['uri-id'] ?? 0; @@ -48,7 +48,7 @@ class APDelivery return; } - Logger::debug('Invoked', ['cmd' => $cmd, 'inbox' => $inbox, 'id' => $item_id, 'uri-id' => $uri_id, 'uid' => $uid]); + DI::logger()->debug('Invoked', ['cmd' => $cmd, 'inbox' => $inbox, 'id' => $item_id, 'uri-id' => $uri_id, 'uid' => $uid]); if (empty($uri_id)) { $result = ActivityPub\Delivery::deliver($inbox); diff --git a/src/Worker/BulkDelivery.php b/src/Worker/BulkDelivery.php index 269a04fa58..3d42424a82 100644 --- a/src/Worker/BulkDelivery.php +++ b/src/Worker/BulkDelivery.php @@ -7,7 +7,6 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; use Friendica\Core\Worker; use Friendica\DI; use Friendica\Model\GServer; @@ -24,7 +23,7 @@ class BulkDelivery foreach ($deliveryQueueItems as $deliveryQueueItem) { if (!$server_failure && ProtocolDelivery::deliver($deliveryQueueItem->command, $deliveryQueueItem->postUriId, $deliveryQueueItem->targetContactId, $deliveryQueueItem->senderUserId)) { DI::deliveryQueueItemRepo()->remove($deliveryQueueItem); - Logger::debug('Delivery successful', $deliveryQueueItem->toArray()); + DI::logger()->debug('Delivery successful', $deliveryQueueItem->toArray()); } else { DI::deliveryQueueItemRepo()->incrementFailed($deliveryQueueItem); $delivery_failure = true; @@ -32,7 +31,7 @@ class BulkDelivery if (!$server_failure) { $server_failure = !GServer::isReachableById($gsid); } - Logger::debug('Delivery failed', ['server_failure' => $server_failure, 'post' => $deliveryQueueItem]); + DI::logger()->debug('Delivery failed', ['server_failure' => $server_failure, 'post' => $deliveryQueueItem]); } } diff --git a/src/Worker/CheckRelMeProfileLink.php b/src/Worker/CheckRelMeProfileLink.php index 0aeaf49c2c..3b0f1800e3 100644 --- a/src/Worker/CheckRelMeProfileLink.php +++ b/src/Worker/CheckRelMeProfileLink.php @@ -9,7 +9,6 @@ namespace Friendica\Worker; use DOMDocument; use Friendica\Content\Text\HTML; -use Friendica\Core\Logger; use Friendica\DI; use Friendica\Model\Profile; use Friendica\Model\User; @@ -41,12 +40,12 @@ class CheckRelMeProfileLink */ public static function execute(int $uid) { - Logger::notice('Verifying the homepage', ['uid' => $uid]); + DI::logger()->notice('Verifying the homepage', ['uid' => $uid]); Profile::update(['homepage_verified' => false], $uid); $owner = User::getOwnerDataById($uid); if (empty($owner['homepage'])) { - Logger::notice('The user has no homepage link.', ['uid' => $uid]); + DI::logger()->notice('The user has no homepage link.', ['uid' => $uid]); return; } @@ -54,31 +53,31 @@ class CheckRelMeProfileLink try { $curlResult = DI::httpClient()->get($owner['homepage'], HttpClientAccept::HTML, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::REQUEST => HttpClientRequest::CONTACTVERIFIER]); } catch (\Throwable $th) { - Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + DI::logger()->notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); return; } if (!$curlResult->isSuccess()) { - Logger::notice('Could not cURL the homepage URL', ['owner homepage' => $owner['homepage']]); + DI::logger()->notice('Could not cURL the homepage URL', ['owner homepage' => $owner['homepage']]); return; } $content = $curlResult->getBodyString(); if (!$content) { - Logger::notice('Empty body of the fetched homepage link). Cannot verify the relation to profile of UID %s.', ['uid' => $uid, 'owner homepage' => $owner['homepage']]); + DI::logger()->notice('Empty body of the fetched homepage link). Cannot verify the relation to profile of UID %s.', ['uid' => $uid, 'owner homepage' => $owner['homepage']]); return; } $doc = new DOMDocument(); if (!@$doc->loadHTML($content)) { - Logger::notice('Could not parse the content'); + DI::logger()->notice('Could not parse the content'); return; } if (HTML::checkRelMeLink($doc, new Uri($owner['url']))) { Profile::update(['homepage_verified' => true], $uid); - Logger::notice('Homepage URL verified', ['uid' => $uid, 'owner homepage' => $owner['homepage']]); + DI::logger()->notice('Homepage URL verified', ['uid' => $uid, 'owner homepage' => $owner['homepage']]); } else { - Logger::notice('Homepage URL could not be verified', ['uid' => $uid, 'owner homepage' => $owner['homepage']]); + DI::logger()->notice('Homepage URL could not be verified', ['uid' => $uid, 'owner homepage' => $owner['homepage']]); } } } diff --git a/src/Worker/CheckVersion.php b/src/Worker/CheckVersion.php index c62cc5f182..2a8f7264ae 100644 --- a/src/Worker/CheckVersion.php +++ b/src/Worker/CheckVersion.php @@ -7,7 +7,6 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Network\HTTPClient\Client\HttpClientAccept; @@ -22,7 +21,7 @@ class CheckVersion { public static function execute() { - Logger::notice('checkversion: start'); + DI::logger()->notice('checkversion: start'); $checkurl = DI::config()->get('system', 'check_new_version_url', 'none'); @@ -38,15 +37,15 @@ class CheckVersion // don't check return; } - Logger::info("Checking VERSION from: ".$checked_url); + DI::logger()->info("Checking VERSION from: ".$checked_url); // fetch the VERSION file $gitversion = DBA::escape(trim(DI::httpClient()->fetch($checked_url, HttpClientAccept::TEXT))); - Logger::notice("Upstream VERSION is: ".$gitversion); + DI::logger()->notice("Upstream VERSION is: ".$gitversion); DI::keyValue()->set('git_friendica_version', $gitversion); - Logger::notice('checkversion: end'); + DI::logger()->notice('checkversion: end'); return; } diff --git a/src/Worker/Cron.php b/src/Worker/Cron.php index c10a548559..3438b9e55a 100644 --- a/src/Worker/Cron.php +++ b/src/Worker/Cron.php @@ -9,7 +9,6 @@ namespace Friendica\Worker; use Friendica\Core\Addon; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\DI; @@ -30,12 +29,12 @@ class Cron if ($last) { $next = $last + ($poll_interval * 60); if ($next > time()) { - Logger::notice('cron interval not reached'); + DI::logger()->notice('cron interval not reached'); return; } } - Logger::notice('start'); + DI::logger()->notice('start'); // Ensure to have a .htaccess file. // this is a precaution for systems that update automatically @@ -151,7 +150,7 @@ class Cron DI::keyValue()->set('last_cron_daily', time()); } - Logger::notice('end'); + DI::logger()->notice('end'); DI::keyValue()->set('last_cron', time()); } @@ -163,7 +162,7 @@ class Cron */ private static function deleteSleepingProcesses() { - Logger::info('Looking for sleeping processes'); + DI::logger()->info('Looking for sleeping processes'); DBA::deleteSleepingProcesses(); } diff --git a/src/Worker/DelayedPublish.php b/src/Worker/DelayedPublish.php index a484ddbc6a..8020a042d4 100644 --- a/src/Worker/DelayedPublish.php +++ b/src/Worker/DelayedPublish.php @@ -7,7 +7,7 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; +use Friendica\DI; use Friendica\Model\Post; class DelayedPublish @@ -26,6 +26,6 @@ class DelayedPublish public static function execute(array $item, int $notify = 0, array $taglist = [], array $attachments = [], int $preparation_mode = Post\Delayed::PREPARED, string $uri = '') { $id = Post\Delayed::publish($item, $notify, $taglist, $attachments, $preparation_mode, $uri); - Logger::notice('Post published', ['id' => $id, 'uid' => $item['uid'], 'notify' => $notify, 'unprepared' => $preparation_mode]); + DI::logger()->notice('Post published', ['id' => $id, 'uid' => $item['uid'], 'notify' => $notify, 'unprepared' => $preparation_mode]); } } diff --git a/src/Worker/Directory.php b/src/Worker/Directory.php index b5025d7710..e9a9102277 100644 --- a/src/Worker/Directory.php +++ b/src/Worker/Directory.php @@ -8,7 +8,6 @@ namespace Friendica\Worker; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Search; use Friendica\Core\Worker; use Friendica\Database\DBA; @@ -40,7 +39,7 @@ class Directory Hook::callAll('globaldir_update', $arr); - Logger::info('Updating directory: ' . $arr['url']); + DI::logger()->info('Updating directory: ' . $arr['url']); if (strlen($arr['url'])) { DI::httpClient()->fetch($dir . '?url=' . bin2hex($arr['url']), HttpClientAccept::HTML, 0, '', HttpClientRequest::CONTACTDISCOVER); } diff --git a/src/Worker/FetchFeaturedPosts.php b/src/Worker/FetchFeaturedPosts.php index de8bc96b9a..be314decb7 100644 --- a/src/Worker/FetchFeaturedPosts.php +++ b/src/Worker/FetchFeaturedPosts.php @@ -7,7 +7,7 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; +use Friendica\DI; use Friendica\Protocol\ActivityPub; class FetchFeaturedPosts @@ -18,8 +18,8 @@ class FetchFeaturedPosts */ public static function execute(string $url) { - Logger::info('Start fetching featured posts', ['url' => $url]); + DI::logger()->info('Start fetching featured posts', ['url' => $url]); ActivityPub\Processor::fetchFeaturedPosts($url); - Logger::info('Finished fetching featured posts', ['url' => $url]); + DI::logger()->info('Finished fetching featured posts', ['url' => $url]); } } diff --git a/src/Worker/FetchMissingActivity.php b/src/Worker/FetchMissingActivity.php index 5b6e8ffd03..4cbc47976d 100644 --- a/src/Worker/FetchMissingActivity.php +++ b/src/Worker/FetchMissingActivity.php @@ -7,7 +7,6 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; use Friendica\Core\Worker; use Friendica\DI; use Friendica\Protocol\ActivityPub; @@ -26,18 +25,18 @@ class FetchMissingActivity */ public static function execute(string $url, array $child = [], string $relay_actor = '', int $completion = Receiver::COMPLETION_MANUAL) { - Logger::info('Start fetching missing activity', ['url' => $url]); + DI::logger()->info('Start fetching missing activity', ['url' => $url]); if (ActivityPub\Processor::alreadyKnown($url, $child['id'] ?? '')) { - Logger::info('Activity is already known.', ['url' => $url]); + DI::logger()->info('Activity is already known.', ['url' => $url]); return; } $result = ActivityPub\Processor::fetchMissingActivity($url, $child, $relay_actor, $completion); if ($result) { - Logger::info('Successfully fetched missing activity', ['url' => $url]); + DI::logger()->info('Successfully fetched missing activity', ['url' => $url]); } elseif (is_null($result)) { - Logger::info('Permament error, activity could not be fetched', ['url' => $url]); + DI::logger()->info('Permament error, activity could not be fetched', ['url' => $url]); } elseif (!Worker::defer(self::WORKER_DEFER_LIMIT)) { - Logger::info('Defer limit reached, activity could not be fetched', ['url' => $url]); + DI::logger()->info('Defer limit reached, activity could not be fetched', ['url' => $url]); // recursively delete all entries that belong to this worker task $queue = DI::appHelper()->getQueue(); @@ -45,7 +44,7 @@ class FetchMissingActivity Queue::deleteByWorkerId($queue['id']); } } else { - Logger::info('Fetching deferred', ['url' => $url]); + DI::logger()->info('Fetching deferred', ['url' => $url]); } } } diff --git a/src/Worker/MergeContact.php b/src/Worker/MergeContact.php index 5c32f80fec..cdb464211b 100644 --- a/src/Worker/MergeContact.php +++ b/src/Worker/MergeContact.php @@ -7,9 +7,9 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\Database\DBStructure; +use Friendica\DI; use Friendica\Model\Contact; class MergeContact @@ -28,7 +28,7 @@ class MergeContact return; } - Logger::info('Handling duplicate', ['search' => $old_cid, 'replace' => $new_cid]); + DI::logger()->info('Handling duplicate', ['search' => $old_cid, 'replace' => $new_cid]); foreach (['item', 'thread', 'post-user', 'post-thread-user'] as $table) { if (DBStructure::existsTable($table)) { diff --git a/src/Worker/NodeInfo.php b/src/Worker/NodeInfo.php index 89fca9a1b3..363d2ce1f9 100644 --- a/src/Worker/NodeInfo.php +++ b/src/Worker/NodeInfo.php @@ -7,7 +7,6 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; use Friendica\DI; use Friendica\Model\Nodeinfo as ModelNodeInfo; use Friendica\Network\HTTPClient\Client\HttpClientAccept; @@ -16,13 +15,13 @@ class NodeInfo { public static function execute() { - Logger::info('start'); + DI::logger()->info('start'); ModelNodeInfo::update(); // Now trying to register $url = 'http://the-federation.info/register/' . DI::baseUrl()->getHost(); - Logger::debug('Check registering url', ['url' => $url]); + DI::logger()->debug('Check registering url', ['url' => $url]); $ret = DI::httpClient()->fetch($url, HttpClientAccept::HTML); - Logger::debug('Check registering answer', ['answer' => $ret]); - Logger::info('end'); + DI::logger()->debug('Check registering answer', ['answer' => $ret]); + DI::logger()->info('end'); } } diff --git a/src/Worker/OptimizeTables.php b/src/Worker/OptimizeTables.php index 853abc3c95..85231a0466 100644 --- a/src/Worker/OptimizeTables.php +++ b/src/Worker/OptimizeTables.php @@ -7,7 +7,6 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\DI; @@ -20,11 +19,11 @@ class OptimizeTables { if (!DI::lock()->acquire('optimize_tables', 0)) { - Logger::warning('Lock could not be acquired'); + DI::logger()->warning('Lock could not be acquired'); return; } - Logger::info('Optimize start'); + DI::logger()->info('Optimize start'); DBA::optimizeTable('cache'); DBA::optimizeTable('locks'); @@ -60,7 +59,7 @@ class OptimizeTables DBA::optimizeTable('tag'); } - Logger::info('Optimize end'); + DI::logger()->info('Optimize end'); DI::lock()->release('optimize_tables'); } diff --git a/src/Worker/PollContacts.php b/src/Worker/PollContacts.php index 66b3cc39da..9a5405bbc5 100644 --- a/src/Worker/PollContacts.php +++ b/src/Worker/PollContacts.php @@ -7,7 +7,6 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Worker; use Friendica\Database\DBA; @@ -52,7 +51,7 @@ class PollContacts $next_update = DateTimeFormat::utc($contact['last-update'] . ' + ' . $interval . ' minute'); if ($now < $next_update) { - Logger::debug('No update', ['cid' => $contact['id'], 'interval' => $interval, 'next' => $next_update, 'now' => $now]); + DI::logger()->debug('No update', ['cid' => $contact['id'], 'interval' => $interval, 'next' => $next_update, 'now' => $now]); continue; } @@ -64,7 +63,7 @@ class PollContacts $priority = Worker::PRIORITY_LOW; } - Logger::notice("Polling " . $contact["network"] . " " . $contact["id"] . " " . $contact['priority'] . " " . $contact["nick"] . " " . $contact["name"]); + DI::logger()->notice("Polling " . $contact["network"] . " " . $contact["id"] . " " . $contact['priority'] . " " . $contact["nick"] . " " . $contact["name"]); Worker::add(['priority' => $priority, 'dont_fork' => true, 'force_priority' => true], 'OnePoll', (int)$contact['id']); Worker::coolDown(); diff --git a/src/Worker/ProfileUpdate.php b/src/Worker/ProfileUpdate.php index 685229b3b5..700da98d8e 100644 --- a/src/Worker/ProfileUpdate.php +++ b/src/Worker/ProfileUpdate.php @@ -7,7 +7,6 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; use Friendica\Core\Worker; use Friendica\DI; use Friendica\Protocol\Delivery; @@ -35,7 +34,7 @@ class ProfileUpdate { $inboxes = ActivityPub\Transmitter::fetchTargetInboxesforUser($uid); foreach ($inboxes as $inbox => $receivers) { - Logger::info('Profile update for user ' . $uid . ' to ' . $inbox .' via ActivityPub'); + DI::logger()->info('Profile update for user ' . $uid . ' to ' . $inbox .' via ActivityPub'); Worker::add(['priority' => $appHelper->getQueueValue('priority'), 'created' => $appHelper->getQueueValue('created'), 'dont_fork' => true], 'APDelivery', Delivery::PROFILEUPDATE, diff --git a/src/Worker/PullDirectory.php b/src/Worker/PullDirectory.php index 4272b91d68..2410be7d96 100644 --- a/src/Worker/PullDirectory.php +++ b/src/Worker/PullDirectory.php @@ -7,7 +7,6 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; use Friendica\Core\Search; use Friendica\DI; use Friendica\Model\Contact; @@ -22,29 +21,29 @@ class PullDirectory public static function execute() { if (!DI::config()->get('system', 'synchronize_directory')) { - Logger::info('Synchronization deactivated'); + DI::logger()->info('Synchronization deactivated'); return; } $directory = Search::getGlobalDirectory(); if (empty($directory)) { - Logger::info('No directory configured'); + DI::logger()->info('No directory configured'); return; } $now = (int)(DI::keyValue()->get('last-directory-sync') ?? 0); - Logger::info('Synchronization started.', ['now' => $now, 'directory' => $directory]); + DI::logger()->info('Synchronization started.', ['now' => $now, 'directory' => $directory]); $result = DI::httpClient()->fetch($directory . '/sync/pull/since/' . $now, HttpClientAccept::JSON, 0, '', HttpClientRequest::CONTACTDISCOVER); if (empty($result)) { - Logger::info('Directory server return empty result.', ['directory' => $directory]); + DI::logger()->info('Directory server return empty result.', ['directory' => $directory]); return; } $contacts = json_decode($result, true); if (empty($contacts['results'])) { - Logger::info('No results fetched.', ['directory' => $directory]); + DI::logger()->info('No results fetched.', ['directory' => $directory]); return; } @@ -53,6 +52,6 @@ class PullDirectory $now = $contacts['now'] ?? 0; DI::keyValue()->set('last-directory-sync', $now); - Logger::info('Synchronization ended', ['now' => $now, 'count' => $result['count'], 'added' => $result['added'], 'updated' => $result['updated'], 'unchanged' => $result['unchanged'], 'directory' => $directory]); + DI::logger()->info('Synchronization ended', ['now' => $now, 'count' => $result['count'], 'added' => $result['added'], 'updated' => $result['updated'], 'unchanged' => $result['unchanged'], 'directory' => $directory]); } } diff --git a/src/Worker/PushSubscription.php b/src/Worker/PushSubscription.php index 4d47a4b18e..b1c07996f1 100644 --- a/src/Worker/PushSubscription.php +++ b/src/Worker/PushSubscription.php @@ -9,7 +9,6 @@ namespace Friendica\Worker; use Friendica\Content\Text\BBCode; use Friendica\Content\Text\Plaintext; -use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Factory\Api\Mastodon\Notification as NotificationFactory; @@ -32,30 +31,30 @@ class PushSubscription */ public static function execute(int $sid, int $nid) { - Logger::info('Start', ['subscription' => $sid, 'notification' => $nid]); + DI::logger()->info('Start', ['subscription' => $sid, 'notification' => $nid]); $subscription = DBA::selectFirst('subscription', [], ['id' => $sid]); if (empty($subscription)) { - Logger::info('Subscription not found', ['subscription' => $sid]); + DI::logger()->info('Subscription not found', ['subscription' => $sid]); return; } try { $notification = DI::notification()->selectOneById($nid); } catch (NotFoundException $e) { - Logger::info('Notification not found', ['notification' => $nid]); + DI::logger()->info('Notification not found', ['notification' => $nid]); return; } $application_token = DBA::selectFirst('application-token', [], ['application-id' => $subscription['application-id'], 'uid' => $subscription['uid']]); if (empty($application_token)) { - Logger::info('Application token not found', ['application' => $subscription['application-id']]); + DI::logger()->info('Application token not found', ['application' => $subscription['application-id']]); return; } $user = User::getById($notification->uid); if (empty($user)) { - Logger::info('User not found', ['application' => $subscription['uid']]); + DI::logger()->info('User not found', ['application' => $subscription['uid']]); return; } @@ -97,7 +96,7 @@ class PushSubscription 'body' => $body ?: $l10n->t('Empty Post'), ]; - Logger::info('Payload', ['payload' => $payload]); + DI::logger()->info('Payload', ['payload' => $payload]); $auth = [ 'VAPID' => [ @@ -114,9 +113,9 @@ class PushSubscription $endpoint = $report->getRequest()->getUri()->__toString(); if ($report->isSuccess()) { - Logger::info('Message sent successfully for subscription', ['subscription' => $sid, 'notification' => $nid, 'endpoint' => $endpoint]); + DI::logger()->info('Message sent successfully for subscription', ['subscription' => $sid, 'notification' => $nid, 'endpoint' => $endpoint]); } else { - Logger::info('Message failed to sent for subscription', ['subscription' => $sid, 'notification' => $nid, 'endpoint' => $endpoint, 'reason' => $report->getReason()]); + DI::logger()->info('Message failed to sent for subscription', ['subscription' => $sid, 'notification' => $nid, 'endpoint' => $endpoint, 'reason' => $report->getReason()]); } } } diff --git a/src/Worker/SearchDirectory.php b/src/Worker/SearchDirectory.php index 0c83ea2d31..ac7242235f 100644 --- a/src/Worker/SearchDirectory.php +++ b/src/Worker/SearchDirectory.php @@ -8,7 +8,6 @@ namespace Friendica\Worker; use Friendica\Core\Cache\Enum\Duration; -use Friendica\Core\Logger; use Friendica\Core\Search; use Friendica\DI; use Friendica\Model\Contact; @@ -21,7 +20,7 @@ class SearchDirectory public static function execute($search) { if (!DI::config()->get('system', 'poco_local_search')) { - Logger::info('Local search is not enabled'); + DI::logger()->info('Local search is not enabled'); return; } @@ -29,7 +28,7 @@ class SearchDirectory if (!is_null($data)) { // Only search for the same item every 24 hours if (time() < $data + (60 * 60 * 24)) { - Logger::info('Already searched this in the last 24 hours', ['search' => $search]); + DI::logger()->info('Already searched this in the last 24 hours', ['search' => $search]); return; } } diff --git a/src/Worker/SetSeen.php b/src/Worker/SetSeen.php index 2428bd8dec..ea26494abd 100644 --- a/src/Worker/SetSeen.php +++ b/src/Worker/SetSeen.php @@ -7,7 +7,7 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; +use Friendica\DI; use Friendica\Model\Item; /** @@ -18,6 +18,6 @@ class SetSeen public static function execute(int $uid) { $ret = Item::update(['unseen' => false], ['unseen' => true, 'uid' => $uid]); - Logger::debug('Set seen', ['uid' => $uid, 'ret' => $ret]); + DI::logger()->debug('Set seen', ['uid' => $uid, 'ret' => $ret]); } } diff --git a/src/Worker/SpoolPost.php b/src/Worker/SpoolPost.php index 9d0a21f5c3..aab2b7a975 100644 --- a/src/Worker/SpoolPost.php +++ b/src/Worker/SpoolPost.php @@ -7,8 +7,8 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; use Friendica\Core\System; +use Friendica\DI; use Friendica\Model\Item; /** @@ -24,7 +24,7 @@ class SpoolPost { // It is not named like a spool file, so we don't care. if (substr($file, 0, 5) != "item-") { - Logger::info('Spool file does not start with "item-"', ['file' => $file]); + DI::logger()->info('Spool file does not start with "item-"', ['file' => $file]); continue; } @@ -32,13 +32,13 @@ class SpoolPost { // We don't care about directories either if (filetype($fullfile) != "file") { - Logger::info('Spool file is no file', ['file' => $file]); + DI::logger()->info('Spool file is no file', ['file' => $file]); continue; } // We can't read or write the file? So we don't care about it. if (!is_writable($fullfile) || !is_readable($fullfile)) { - Logger::warning('Spool file has insufficent permissions', ['file' => $file, 'writable' => is_writable($fullfile), 'readable' => is_readable($fullfile)]); + DI::logger()->warning('Spool file has insufficent permissions', ['file' => $file, 'writable' => is_writable($fullfile), 'readable' => is_readable($fullfile)]); continue; } @@ -46,19 +46,19 @@ class SpoolPost { // If it isn't an array then it is no spool file if (!is_array($arr)) { - Logger::notice('Spool file is no array', ['file' => $file]); + DI::logger()->notice('Spool file is no array', ['file' => $file]); continue; } // Skip if it doesn't seem to be an item array if (!isset($arr['uid']) && !isset($arr['uri']) && !isset($arr['network'])) { - Logger::warning('Spool file does not contain the needed fields', ['file' => $file]); + DI::logger()->warning('Spool file does not contain the needed fields', ['file' => $file]); continue; } $result = Item::insert($arr); - Logger::info('Spool file is stored', ['file' => $file, 'result' => $result]); + DI::logger()->info('Spool file is stored', ['file' => $file, 'result' => $result]); unlink($fullfile); } closedir($dh);