diff --git a/src/Worker/UpdateBlockedServers.php b/src/Worker/UpdateBlockedServers.php index 61ea6ab0eb..ab38a5dd85 100644 --- a/src/Worker/UpdateBlockedServers.php +++ b/src/Worker/UpdateBlockedServers.php @@ -7,7 +7,6 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\GServer; @@ -20,7 +19,7 @@ class UpdateBlockedServers */ public static function execute() { - Logger::info('Update blocked servers - start'); + DI::logger()->info('Update blocked servers - start'); $gservers = DBA::select('gserver', ['id', 'url', 'blocked']); $changed = 0; $unchanged = 0; @@ -39,12 +38,12 @@ class UpdateBlockedServers $changed++; } DBA::close($gservers); - Logger::info('Update blocked servers - done', ['changed' => $changed, 'unchanged' => $unchanged]); + DI::logger()->info('Update blocked servers - done', ['changed' => $changed, 'unchanged' => $unchanged]); if (DI::config()->get('system', 'delete-blocked-servers')) { - Logger::info('Delete blocked servers - start'); + DI::logger()->info('Delete blocked servers - start'); $ret = DBA::delete('gserver', ["`blocked` AND NOT EXISTS(SELECT `gsid` FROM `inbox-status` WHERE `gsid` = `gserver`.`id`) AND NOT EXISTS(SELECT `gsid` FROM `contact` WHERE gsid= `gserver`.`id`) AND NOT EXISTS(SELECT `gsid` FROM `apcontact` WHERE `gsid` = `gserver`.`id`) AND NOT EXISTS(SELECT `gsid` FROM `delivery-queue` WHERE `gsid` = `gserver`.`id`) AND NOT EXISTS(SELECT `gsid` FROM `diaspora-contact` WHERE `gsid` = `gserver`.`id`) AND NOT EXISTS(SELECT `gserver-id` FROM `gserver-tag` WHERE `gserver-id` = `gserver`.`id`)"]); - Logger::info('Delete blocked servers - done', ['ret' => $ret, 'rows' => DBA::affectedRows()]); + DI::logger()->info('Delete blocked servers - done', ['ret' => $ret, 'rows' => DBA::affectedRows()]); } } } diff --git a/src/Worker/UpdateContact.php b/src/Worker/UpdateContact.php index aad6a93db2..059a8134c5 100644 --- a/src/Worker/UpdateContact.php +++ b/src/Worker/UpdateContact.php @@ -7,8 +7,8 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; use Friendica\Core\Worker; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Network\HTTPException\InternalServerErrorException; @@ -31,7 +31,7 @@ class UpdateContact $success = Contact::updateFromProbe($contact_id); - Logger::info('Updated from probe', ['id' => $contact_id, 'success' => $success]); + DI::logger()->info('Updated from probe', ['id' => $contact_id, 'success' => $success]); } /** diff --git a/src/Worker/UpdateContacts.php b/src/Worker/UpdateContacts.php index 92c97beff2..bb7e236661 100644 --- a/src/Worker/UpdateContacts.php +++ b/src/Worker/UpdateContacts.php @@ -7,7 +7,6 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\DI; @@ -30,11 +29,11 @@ class UpdateContacts $updating = Worker::countWorkersByCommand('UpdateContact'); $limit = $update_limit - $updating; if ($limit <= 0) { - Logger::info('The number of currently running jobs exceed the limit'); + DI::logger()->info('The number of currently running jobs exceed the limit'); return; } - Logger::info('Updating contact', ['count' => $limit]); + DI::logger()->info('Updating contact', ['count' => $limit]); $condition = ['self' => false]; @@ -54,20 +53,20 @@ class UpdateContacts if ((!empty($contact['gsid']) || !empty($contact['baseurl'])) && GServer::reachable($contact)) { $stamp = (float)microtime(true); $success = Contact::updateFromProbe($contact['id']); - Logger::debug('Direct update', ['id' => $contact['id'], 'count' => $count, 'duration' => round((float)microtime(true) - $stamp, 3), 'success' => $success]); + DI::logger()->debug('Direct update', ['id' => $contact['id'], 'count' => $count, 'duration' => round((float)microtime(true) - $stamp, 3), 'success' => $success]); ++$count; } elseif (UpdateContact::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], $contact['id'])) { - Logger::debug('Update by worker', ['id' => $contact['id'], 'count' => $count]); + DI::logger()->debug('Update by worker', ['id' => $contact['id'], 'count' => $count]); ++$count; } } catch (\InvalidArgumentException $e) { - Logger::notice($e->getMessage(), ['contact' => $contact]); + DI::logger()->notice($e->getMessage(), ['contact' => $contact]); } Worker::coolDown(); } DBA::close($contacts); - Logger::info('Initiated update for federated contacts', ['count' => $count]); + DI::logger()->info('Initiated update for federated contacts', ['count' => $count]); } } diff --git a/src/Worker/UpdateGServer.php b/src/Worker/UpdateGServer.php index 7fd6057a92..1c95631da4 100644 --- a/src/Worker/UpdateGServer.php +++ b/src/Worker/UpdateGServer.php @@ -7,15 +7,13 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; use Friendica\Core\Worker; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\GServer; use Friendica\Network\HTTPException\InternalServerErrorException; use Friendica\Util\Network; use Friendica\Util\Strings; -use GuzzleHttp\Psr7\Uri; -use Psr\Http\Message\UriInterface; class UpdateGServer { @@ -62,7 +60,7 @@ class UpdateGServer } $ret = GServer::check($filtered, '', true, $only_nodeinfo); - Logger::info('Updated gserver', ['url' => $filtered, 'result' => $ret]); + DI::logger()->info('Updated gserver', ['url' => $filtered, 'result' => $ret]); } /** diff --git a/src/Worker/UpdateGServers.php b/src/Worker/UpdateGServers.php index d40d86f844..a5eb626dba 100644 --- a/src/Worker/UpdateGServers.php +++ b/src/Worker/UpdateGServers.php @@ -7,7 +7,6 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\DI; @@ -31,14 +30,14 @@ class UpdateGServers $updating = Worker::countWorkersByCommand('UpdateGServer'); $limit = $update_limit - $updating; if ($limit <= 0) { - Logger::info('The number of currently running jobs exceed the limit'); + DI::logger()->info('The number of currently running jobs exceed the limit'); return; } $total = DBA::count('gserver'); $condition = ["NOT `blocked` AND `next_contact` < ? AND (`nurl` != ? OR `url` != ?)", DateTimeFormat::utcNow(), '', '']; $outdated = DBA::count('gserver', $condition); - Logger::info('Server status', ['total' => $total, 'outdated' => $outdated, 'updating' => $limit]); + DI::logger()->info('Server status', ['total' => $total, 'outdated' => $outdated, 'updating' => $limit]); $gservers = DBA::select('gserver', ['id', 'url', 'nurl', 'failed', 'created', 'last_contact'], $condition, ['limit' => $limit]); if (!DBA::isResult($gservers)) { @@ -49,7 +48,7 @@ class UpdateGServers while ($gserver = DBA::fetch($gservers)) { if (DI::config()->get('system', 'update_active_contacts') && !Contact::exists(['gsid' => $gserver['id'], 'local-data' => true])) { $next_update = GServer::getNextUpdateDate(!$gserver['failed'], $gserver['created'], $gserver['last_contact']); - Logger::debug('Skip server without contacts with local data', ['url' => $gserver['url'], 'failed' => $gserver['failed'], 'next_update' => $next_update]); + DI::logger()->debug('Skip server without contacts with local data', ['url' => $gserver['url'], 'failed' => $gserver['failed'], 'next_update' => $next_update]); GServer::update(['next_contact' => $next_update], ['nurl' => $gserver['nurl']]); continue; } @@ -70,6 +69,6 @@ class UpdateGServers Worker::coolDown(); } DBA::close($gservers); - Logger::info('Updated servers', ['count' => $count]); + DI::logger()->info('Updated servers', ['count' => $count]); } } diff --git a/src/Worker/UpdateScores.php b/src/Worker/UpdateScores.php index ffba5fd3ac..c2086e8cba 100644 --- a/src/Worker/UpdateScores.php +++ b/src/Worker/UpdateScores.php @@ -7,19 +7,19 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact\Relation; use Friendica\Model\Post; /** - * Update the interaction scores + * Update the interaction scores */ class UpdateScores { public static function execute($param = '', $hook_function = '') { - Logger::notice('Start score update'); + DI::logger()->notice('Start score update'); $users = DBA::select('user', ['uid'], ["`verified` AND NOT `blocked` AND NOT `account_removed` AND NOT `account_expired` AND `uid` > ?", 0]); while ($user = DBA::fetch($users)) { @@ -27,7 +27,7 @@ class UpdateScores } DBA::close($users); - Logger::notice('Score update done'); + DI::logger()->notice('Score update done'); Post\Engagement::expire(); diff --git a/src/Worker/UpdateServerDirectory.php b/src/Worker/UpdateServerDirectory.php index cf3634d878..e9482124e8 100644 --- a/src/Worker/UpdateServerDirectory.php +++ b/src/Worker/UpdateServerDirectory.php @@ -7,7 +7,6 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\GServer; @@ -38,17 +37,17 @@ class UpdateServerDirectory { $result = DI::httpClient()->fetch($gserver['poco'] . '?fields=urls', HttpClientAccept::JSON, 0, '', HttpClientRequest::SERVERDISCOVER); if (empty($result)) { - Logger::info('Empty result', ['url' => $gserver['url']]); + DI::logger()->info('Empty result', ['url' => $gserver['url']]); return; } $contacts = json_decode($result, true); if (empty($contacts['entry'])) { - Logger::info('No contacts', ['url' => $gserver['url']]); + DI::logger()->info('No contacts', ['url' => $gserver['url']]); return; } - Logger::info('PoCo discovery started', ['poco' => $gserver['poco']]); + DI::logger()->info('PoCo discovery started', ['poco' => $gserver['poco']]); $urls = []; foreach (array_column($contacts['entry'], 'urls') as $url_entries) { @@ -64,24 +63,24 @@ class UpdateServerDirectory $result = Contact::addByUrls($urls); - Logger::info('PoCo discovery ended', ['count' => $result['count'], 'added' => $result['added'], 'updated' => $result['updated'], 'unchanged' => $result['unchanged'], 'poco' => $gserver['poco']]); + DI::logger()->info('PoCo discovery ended', ['count' => $result['count'], 'added' => $result['added'], 'updated' => $result['updated'], 'unchanged' => $result['unchanged'], 'poco' => $gserver['poco']]); } private static function discoverMastodonDirectory(array $gserver) { $result = DI::httpClient()->fetch($gserver['url'] . '/api/v1/directory?order=new&local=true&limit=200&offset=0', HttpClientAccept::JSON, 0, '', HttpClientRequest::SERVERDISCOVER); if (empty($result)) { - Logger::info('Empty result', ['url' => $gserver['url']]); + DI::logger()->info('Empty result', ['url' => $gserver['url']]); return; } $accounts = json_decode($result, true); if (!is_array($accounts)) { - Logger::info('No contacts', ['url' => $gserver['url']]); + DI::logger()->info('No contacts', ['url' => $gserver['url']]); return; } - Logger::info('Account discovery started', ['url' => $gserver['url']]); + DI::logger()->info('Account discovery started', ['url' => $gserver['url']]); $urls = []; foreach ($accounts as $account) { @@ -92,6 +91,6 @@ class UpdateServerDirectory $result = Contact::addByUrls($urls); - Logger::info('Account discovery ended', ['count' => $result['count'], 'added' => $result['added'], 'updated' => $result['updated'], 'unchanged' => $result['unchanged'], 'url' => $gserver['url']]); + DI::logger()->info('Account discovery ended', ['count' => $result['count'], 'added' => $result['added'], 'updated' => $result['updated'], 'unchanged' => $result['unchanged'], 'url' => $gserver['url']]); } } diff --git a/src/Worker/UpdateServerPeers.php b/src/Worker/UpdateServerPeers.php index 94e04a240d..4d3846b643 100644 --- a/src/Worker/UpdateServerPeers.php +++ b/src/Worker/UpdateServerPeers.php @@ -7,7 +7,6 @@ namespace Friendica\Worker; -use Friendica\Core\Logger; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\DI; @@ -35,21 +34,21 @@ class UpdateServerPeers try { $ret = DI::httpClient()->get($url . '/api/v1/instance/peers', HttpClientAccept::JSON, [HttpClientOptions::REQUEST => HttpClientRequest::SERVERDISCOVER]); } 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 (!$ret->isSuccess() || empty($ret->getBodyString())) { - Logger::info('Server is not reachable or does not offer the "peers" endpoint', ['url' => $url]); + DI::logger()->info('Server is not reachable or does not offer the "peers" endpoint', ['url' => $url]); return; } $peers = json_decode($ret->getBodyString()); if (empty($peers) || !is_array($peers)) { - Logger::info('Server does not have any peers listed', ['url' => $url]); + DI::logger()->info('Server does not have any peers listed', ['url' => $url]); return; } - Logger::info('Server peer update start', ['url' => $url]); + DI::logger()->info('Server peer update start', ['url' => $url]); $total = 0; $added = 0; @@ -69,6 +68,6 @@ class UpdateServerPeers ++$added; Worker::coolDown(); } - Logger::info('Server peer update ended', ['total' => $total, 'added' => $added, 'url' => $url]); + DI::logger()->info('Server peer update ended', ['total' => $total, 'added' => $added, 'url' => $url]); } }