diff --git a/advancedcontentfilter/advancedcontentfilter.php b/advancedcontentfilter/advancedcontentfilter.php index c03034cd..aeeff77c 100644 --- a/advancedcontentfilter/advancedcontentfilter.php +++ b/advancedcontentfilter/advancedcontentfilter.php @@ -36,7 +36,6 @@ use Friendica\BaseModule; use Friendica\Content\Text\Markdown; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\Database\DBStructure; @@ -62,7 +61,7 @@ function advancedcontentfilter_install() Hook::add('dbstructure_definition' , __FILE__, 'advancedcontentfilter_dbstructure_definition'); DBStructure::performUpdate(); - Logger::notice('installed advancedcontentfilter'); + DI::logger()->notice('installed advancedcontentfilter'); } /* diff --git a/birdavatar/birdavatar.php b/birdavatar/birdavatar.php index 9a9dce0a..cd49b183 100644 --- a/birdavatar/birdavatar.php +++ b/birdavatar/birdavatar.php @@ -7,7 +7,6 @@ */ use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\DI; @@ -27,7 +26,7 @@ function birdavatar_install() Hook::register('addon_settings', __FILE__, 'birdavatar_addon_settings'); Hook::register('addon_settings_post', __FILE__, 'birdavatar_addon_settings_post'); - Logger::info('registered birdavatar'); + DI::logger()->info('registered birdavatar'); } /** diff --git a/blackout/blackout.php b/blackout/blackout.php index a3f806ff..ac1ee3e6 100644 --- a/blackout/blackout.php +++ b/blackout/blackout.php @@ -45,7 +45,6 @@ */ use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\DI; @@ -77,7 +76,7 @@ function blackout_redirect ($b) } if (( $date1 <= $now ) && ( $now <= $date2 )) { - Logger::notice('redirecting user to blackout page'); + DI::logger()->notice('redirecting user to blackout page'); System::externalRedirect($myurl); } } diff --git a/blockbot/blockbot.php b/blockbot/blockbot.php index 022f188d..163d0cbc 100644 --- a/blockbot/blockbot.php +++ b/blockbot/blockbot.php @@ -11,7 +11,6 @@ use Friendica\Core\Hook; use Friendica\DI; use Jaybizzle\CrawlerDetect\CrawlerDetect; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Network\HTTPException\ForbiddenException; @@ -70,7 +69,7 @@ function blockbot_init_1() } if (empty($parts)) { - Logger::debug('Known frontend found - accept', $logdata); + DI::logger()->debug('Known frontend found - accept', $logdata); if ($isCrawler) { blockbot_save('badly-parsed-agents', $_SERVER['HTTP_USER_AGENT']); } @@ -80,66 +79,66 @@ function blockbot_init_1() blockbot_log_activitypub($_SERVER['REQUEST_URI'], $_SERVER['HTTP_USER_AGENT']); if (blockbot_is_crawler($parts)) { - Logger::debug('Crawler found - reject', $logdata); + DI::logger()->debug('Crawler found - reject', $logdata); blockbot_reject(); } if (blockbot_is_searchbot($parts)) { - Logger::debug('Search bot found - reject', $logdata); + DI::logger()->debug('Search bot found - reject', $logdata); blockbot_reject(); } if (blockbot_is_unwanted($parts)) { - Logger::debug('Uncategorized unwanted agent found - reject', $logdata); + DI::logger()->debug('Uncategorized unwanted agent found - reject', $logdata); blockbot_reject(); } if (blockbot_is_security_checker($parts)) { if (!DI::config()->get('blockbot', 'security_checker')) { - Logger::debug('Security checker found - reject', $logdata); + DI::logger()->debug('Security checker found - reject', $logdata); blockbot_reject(); } - Logger::debug('Security checker found - accept', $logdata); + DI::logger()->debug('Security checker found - accept', $logdata); return; } if (blockbot_is_social_media($parts)) { - Logger::debug('Social media service found - accept', $logdata); + DI::logger()->debug('Social media service found - accept', $logdata); return; } if (blockbot_is_fediverse_client($parts)) { - Logger::debug('Fediverse client found - accept', $logdata); + DI::logger()->debug('Fediverse client found - accept', $logdata); return; } if (blockbot_is_feed_reader($parts)) { - Logger::debug('Feed reader found - accept', $logdata); + DI::logger()->debug('Feed reader found - accept', $logdata); return; } if (blockbot_is_fediverse_tool($parts)) { - Logger::debug('Fediverse tool found - accept', $logdata); + DI::logger()->debug('Fediverse tool found - accept', $logdata); return; } if (blockbot_is_service_agent($parts)) { - Logger::debug('Service agent found - accept', $logdata); + DI::logger()->debug('Service agent found - accept', $logdata); return; } if (blockbot_is_monitor($parts)) { - Logger::debug('Monitoring service found - accept', $logdata); + DI::logger()->debug('Monitoring service found - accept', $logdata); return; } if (blockbot_is_validator($parts)) { - Logger::debug('Validation service found - accept', $logdata); + DI::logger()->debug('Validation service found - accept', $logdata); return; } if (blockbot_is_good_tool($parts)) { - Logger::debug('Uncategorized helpful service found - accept', $logdata); + DI::logger()->debug('Uncategorized helpful service found - accept', $logdata); return; } @@ -147,10 +146,10 @@ function blockbot_init_1() if (blockbot_is_http_library($parts)) { blockbot_check_login_attempt($_SERVER['REQUEST_URI'], $logdata); if (!DI::config()->get('blockbot', 'http_libraries')) { - Logger::debug('HTTP Library found - reject', $logdata); + DI::logger()->debug('HTTP Library found - reject', $logdata); blockbot_reject(); } - Logger::debug('HTTP Library found - accept', $logdata); + DI::logger()->debug('HTTP Library found - accept', $logdata); return; } @@ -161,12 +160,12 @@ function blockbot_init_1() if (!$isCrawler) { blockbot_save('good-agents', $_SERVER['HTTP_USER_AGENT']); - Logger::debug('Non-bot user agent detected', $logdata); + DI::logger()->debug('Non-bot user agent detected', $logdata); return; } blockbot_save('bad-agents', $_SERVER['HTTP_USER_AGENT']); - Logger::notice('Possible bot found - reject', $logdata); + DI::logger()->notice('Possible bot found - reject', $logdata); blockbot_reject(); } @@ -217,7 +216,7 @@ function blockbot_log_activitypub(string $url, string $agent) function blockbot_check_login_attempt(string $url, array $logdata) { if (in_array(trim(parse_url($url, PHP_URL_PATH), '/'), ['login', 'lostpass', 'register'])) { - Logger::debug('Login attempt detected - reject', $logdata); + DI::logger()->debug('Login attempt detected - reject', $logdata); blockbot_reject(); } } @@ -443,7 +442,7 @@ function blockbot_is_monitor(array $parts): bool } /** - * Services in the centralized and decentralized social media environment + * Services in the centralized and decentralized social media environment * * @param array $parts * @return boolean diff --git a/bluesky/bluesky.php b/bluesky/bluesky.php index 5bf07afb..7f6bb9e7 100644 --- a/bluesky/bluesky.php +++ b/bluesky/bluesky.php @@ -30,7 +30,6 @@ use Friendica\Content\Text\Plaintext; use Friendica\Core\Cache\Enum\Duration; use Friendica\Core\Config\Util\ConfigFileManager; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Core\Worker; @@ -106,16 +105,16 @@ function bluesky_item_by_link(array &$hookData) if (empty($did)) { return; } - - Logger::debug('Found bluesky post', ['uri' => $hookData['uri'], 'did' => $did, 'cid' => $matches[2]]); - + + DI::logger()->debug('Found bluesky post', ['uri' => $hookData['uri'], 'did' => $did, 'cid' => $matches[2]]); + $uri = 'at://' . $did . '/app.bsky.feed.post/' . $matches[2]; } else { $uri = $hookData['uri']; } $uri = DI::atpProcessor()->fetchMissingPost($uri, $hookData['uid'], Item::PR_FETCHED, 0, 0); - Logger::debug('Got post', ['uri' => $uri]); + DI::logger()->debug('Got post', ['uri' => $uri]); if (!empty($uri)) { $item = Post::selectFirst(['id'], ['uri' => $uri, 'uid' => $hookData['uid']]); if (!empty($item['id'])) { @@ -138,7 +137,7 @@ function bluesky_follow(array &$hook_data) return; } - Logger::debug('Check if contact is bluesky', ['data' => $hook_data]); + DI::logger()->debug('Check if contact is bluesky', ['data' => $hook_data]); $contact = DBA::selectFirst('contact', [], ['network' => Protocol::BLUESKY, 'url' => $hook_data['url'], 'uid' => [0, $hook_data['uid']]]); if (empty($contact)) { return; @@ -159,7 +158,7 @@ function bluesky_follow(array &$hook_data) $activity = DI::atProtocol()->XRPCPost($hook_data['uid'], 'com.atproto.repo.createRecord', $post); if (!empty($activity->uri)) { $hook_data['contact'] = $contact; - Logger::debug('Successfully start following', ['url' => $contact['url'], 'uri' => $activity->uri]); + DI::logger()->debug('Successfully start following', ['url' => $contact['url'], 'uri' => $activity->uri]); } } @@ -213,7 +212,7 @@ function bluesky_block(array &$hook_data) if ($ucid) { Contact::remove($ucid); } - Logger::debug('Successfully blocked contact', ['url' => $hook_data['contact']['url'], 'uri' => $activity->uri]); + DI::logger()->debug('Successfully blocked contact', ['url' => $hook_data['contact']['url'], 'uri' => $activity->uri]); } } @@ -421,11 +420,11 @@ function bluesky_cron() if ($last) { $next = $last + ($poll_interval * 60); if ($next > time()) { - Logger::notice('poll interval not reached'); + DI::logger()->notice('poll interval not reached'); return; } } - Logger::notice('cron_start'); + DI::logger()->notice('cron_start'); $abandon_days = intval(DI::config()->get('system', 'account_abandon_days')); if ($abandon_days < 1) { @@ -437,19 +436,19 @@ function bluesky_cron() $pconfigs = DBA::selectToArray('pconfig', [], ["`cat` = ? AND `k` IN (?, ?) AND `v`", 'bluesky', 'import', 'import_feeds']); foreach ($pconfigs as $pconfig) { if (empty(DI::atProtocol()->getUserDid($pconfig['uid']))) { - Logger::debug('User has got no valid DID', ['uid' => $pconfig['uid']]); + DI::logger()->debug('User has got no valid DID', ['uid' => $pconfig['uid']]); continue; } if ($abandon_days != 0) { if (!DBA::exists('user', ["`uid` = ? AND `login_date` >= ?", $pconfig['uid'], $abandon_limit])) { - Logger::notice('abandoned account: timeline from user will not be imported', ['user' => $pconfig['uid']]); + DI::logger()->notice('abandoned account: timeline from user will not be imported', ['user' => $pconfig['uid']]); continue; } } // Refresh the token now, so that it doesn't need to be refreshed in parallel by the following workers - Logger::debug('Refresh the token', ['uid' => $pconfig['uid']]); + DI::logger()->debug('Refresh the token', ['uid' => $pconfig['uid']]); DI::atProtocol()->getUserToken($pconfig['uid']); $last_sync = DI::pConfig()->get($pconfig['uid'], 'bluesky', 'last_contact_sync'); @@ -463,32 +462,32 @@ function bluesky_cron() Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], 'addon/bluesky/bluesky_timeline.php', $pconfig['uid']); } if (DI::pConfig()->get($pconfig['uid'], 'bluesky', 'import_feeds')) { - Logger::debug('Fetch feeds for user', ['uid' => $pconfig['uid']]); + DI::logger()->debug('Fetch feeds for user', ['uid' => $pconfig['uid']]); $feeds = bluesky_get_feeds($pconfig['uid']); foreach ($feeds as $feed) { Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], 'addon/bluesky/bluesky_feed.php', $pconfig['uid'], $feed); } } - Logger::debug('Polling done for user', ['uid' => $pconfig['uid']]); + DI::logger()->debug('Polling done for user', ['uid' => $pconfig['uid']]); } - Logger::notice('Polling done for all users'); + DI::logger()->notice('Polling done for all users'); DI::keyValue()->set('bluesky_last_poll', time()); $last_clean = DI::keyValue()->get('bluesky_last_clean'); if (empty($last_clean) || ($last_clean + 86400 < time())) { - Logger::notice('Start contact cleanup'); + DI::logger()->notice('Start contact cleanup'); $contacts = DBA::select('account-user-view', ['id', 'pid'], ["`network` = ? AND `uid` != ? AND `rel` = ?", Protocol::BLUESKY, 0, Contact::NOTHING]); while ($contact = DBA::fetch($contacts)) { Worker::add(Worker::PRIORITY_LOW, 'MergeContact', $contact['pid'], $contact['id'], 0); } DBA::close($contacts); DI::keyValue()->set('bluesky_last_clean', time()); - Logger::notice('Contact cleanup done'); + DI::logger()->notice('Contact cleanup done'); } - Logger::notice('cron_end'); + DI::logger()->notice('cron_end'); } function bluesky_hook_fork(array &$b) @@ -508,7 +507,7 @@ function bluesky_hook_fork(array &$b) if (DI::pConfig()->get($post['uid'], 'bluesky', 'import')) { // Don't post if it isn't a reply to a bluesky post if (($post['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::BLUESKY])) { - Logger::notice('No bluesky parent found', ['item' => $post['id']]); + DI::logger()->notice('No bluesky parent found', ['item' => $post['id']]); $b['execute'] = false; return; } @@ -555,12 +554,12 @@ function bluesky_send(array &$b) } if ($b['gravity'] != Item::GRAVITY_PARENT) { - Logger::debug('Got comment', ['item' => $b]); + DI::logger()->debug('Got comment', ['item' => $b]); if ($b['deleted']) { $uri = DI::atpProcessor()->getUriClass($b['uri']); if (empty($uri)) { - Logger::debug('Not a bluesky post', ['uri' => $b['uri']]); + DI::logger()->debug('Not a bluesky post', ['uri' => $b['uri']]); return; } bluesky_delete_post($b['uri'], $b['uid']); @@ -571,12 +570,12 @@ function bluesky_send(array &$b) $parent = DI::atpProcessor()->getUriClass($b['thr-parent']); if (empty($root) || empty($parent)) { - Logger::debug('No bluesky post', ['parent' => $b['parent'], 'thr-parent' => $b['thr-parent']]); + DI::logger()->debug('No bluesky post', ['parent' => $b['parent'], 'thr-parent' => $b['thr-parent']]); return; } if ($b['gravity'] == Item::GRAVITY_COMMENT) { - Logger::debug('Posting comment', ['root' => $root, 'parent' => $parent]); + DI::logger()->debug('Posting comment', ['root' => $root, 'parent' => $parent]); bluesky_create_post($b, $root, $parent); return; } elseif (in_array($b['verb'], [Activity::LIKE, Activity::ANNOUNCE])) { @@ -635,10 +634,10 @@ function bluesky_create_activity(array $item, stdClass $parent = null) if (empty($activity->uri)) { return; } - Logger::debug('Activity done', ['return' => $activity]); + DI::logger()->debug('Activity done', ['return' => $activity]); $uri = DI::atpProcessor()->getUri($activity); Item::update(['extid' => $uri], ['guid' => $item['guid']]); - Logger::debug('Set extid', ['id' => $item['id'], 'extid' => $activity]); + DI::logger()->debug('Set extid', ['id' => $item['id'], 'extid' => $activity]); } function bluesky_create_post(array $item, stdClass $root = null, stdClass $parent = null) @@ -722,14 +721,14 @@ function bluesky_create_post(array $item, stdClass $root = null, stdClass $paren } return; } - Logger::debug('Posting done', ['return' => $parent]); + DI::logger()->debug('Posting done', ['return' => $parent]); if (empty($root)) { $root = $parent; } if (($key == 0) && ($item['gravity'] != Item::GRAVITY_PARENT)) { $uri = DI::atpProcessor()->getUri($parent); Item::update(['extid' => $uri], ['guid' => $item['guid']]); - Logger::debug('Set extid', ['id' => $item['id'], 'extid' => $uri]); + DI::logger()->debug('Set extid', ['id' => $item['id'], 'extid' => $uri]); } } } @@ -899,20 +898,20 @@ function bluesky_upload_blob(int $uid, array $photo): ?stdClass $new_size = strlen($content); if (($size != 0) && ($new_size == 0) && ($retrial == 0)) { - Logger::warning('Size is empty after resize, uploading original file', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]); + DI::logger()->warning('Size is empty after resize, uploading original file', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]); $content = Photo::getImageForPhoto($photo); } else { - Logger::info('Uploading', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]); + DI::logger()->info('Uploading', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]); } $data = DI::atProtocol()->post($uid, '/xrpc/com.atproto.repo.uploadBlob', $content, ['Content-type' => $photo['type'], 'Authorization' => ['Bearer ' . DI::atProtocol()->getUserToken($uid)]]); if (empty($data) || empty($data->blob)) { - Logger::info('Uploading failed', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]); + DI::logger()->info('Uploading failed', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]); return null; } Item::incrementOutbound(Protocol::BLUESKY); - Logger::debug('Uploaded blob', ['return' => $data, 'uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]); + DI::logger()->debug('Uploaded blob', ['return' => $data, 'uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]); return $data->blob; } @@ -920,11 +919,11 @@ function bluesky_delete_post(string $uri, int $uid) { $parts = DI::atpProcessor()->getUriParts($uri); if (empty($parts)) { - Logger::debug('No uri delected', ['uri' => $uri]); + DI::logger()->debug('No uri delected', ['uri' => $uri]); return; } DI::atProtocol()->XRPCPost($uid, 'com.atproto.repo.deleteRecord', $parts); - Logger::debug('Deleted', ['parts' => $parts]); + DI::logger()->debug('Deleted', ['parts' => $parts]); } function bluesky_fetch_timeline(int $uid) @@ -1026,10 +1025,10 @@ function bluesky_fetch_notifications(int $uid) foreach ($data->notifications as $notification) { $uri = DI::atpProcessor()->getUri($notification); if (Post::exists(['uri' => $uri, 'uid' => $uid]) || Post::exists(['extid' => $uri, 'uid' => $uid])) { - Logger::debug('Notification already processed', ['uid' => $uid, 'reason' => $notification->reason, 'uri' => $uri, 'indexedAt' => $notification->indexedAt]); + DI::logger()->debug('Notification already processed', ['uid' => $uid, 'reason' => $notification->reason, 'uri' => $uri, 'indexedAt' => $notification->indexedAt]); continue; } - Logger::debug('Process notification', ['uid' => $uid, 'reason' => $notification->reason, 'uri' => $uri, 'indexedAt' => $notification->indexedAt]); + DI::logger()->debug('Process notification', ['uid' => $uid, 'reason' => $notification->reason, 'uri' => $uri, 'indexedAt' => $notification->indexedAt]); switch ($notification->reason) { case 'like': $item = DI::atpProcessor()->getHeaderFromPost($notification, $uri, $uid, Conversation::PARCEL_CONNECTOR); @@ -1039,9 +1038,9 @@ function bluesky_fetch_notifications(int $uid) $item['thr-parent'] = DI::atpProcessor()->fetchMissingPost($item['thr-parent'], $uid, Item::PR_FETCHED, $item['contact-id'], 0); if (!empty($item['thr-parent'])) { $data = Item::insert($item); - Logger::debug('Got like', ['uid' => $uid, 'result' => $data, 'uri' => $uri]); + DI::logger()->debug('Got like', ['uid' => $uid, 'result' => $data, 'uri' => $uri]); } else { - Logger::info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]); + DI::logger()->info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]); } break; @@ -1053,37 +1052,37 @@ function bluesky_fetch_notifications(int $uid) $item['thr-parent'] = DI::atpProcessor()->fetchMissingPost($item['thr-parent'], $uid, Item::PR_FETCHED, $item['contact-id'], 0); if (!empty($item['thr-parent'])) { $data = Item::insert($item); - Logger::debug('Got repost', ['uid' => $uid, 'result' => $data, 'uri' => $uri]); + DI::logger()->debug('Got repost', ['uid' => $uid, 'result' => $data, 'uri' => $uri]); } else { - Logger::info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]); + DI::logger()->info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]); } break; case 'follow': $contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, $uid); - Logger::debug('New follower', ['uid' => $uid, 'nick' => $contact['nick'], 'uri' => $uri]); + DI::logger()->debug('New follower', ['uid' => $uid, 'nick' => $contact['nick'], 'uri' => $uri]); break; case 'mention': $contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, 0); $result = DI::atpProcessor()->fetchMissingPost($uri, $uid, Item::PR_TO, $contact['id'], 0); - Logger::debug('Got mention', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]); + DI::logger()->debug('Got mention', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]); break; case 'reply': $contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, 0); $result = DI::atpProcessor()->fetchMissingPost($uri, $uid, Item::PR_COMMENT, $contact['id'], 0); - Logger::debug('Got reply', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]); + DI::logger()->debug('Got reply', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]); break; case 'quote': $contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, 0); $result = DI::atpProcessor()->fetchMissingPost($uri, $uid, Item::PR_PUSHED, $contact['id'], 0); - Logger::debug('Got quote', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]); + DI::logger()->debug('Got quote', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]); break; default: - Logger::notice('Unhandled reason', ['reason' => $notification->reason, 'uri' => $uri]); + DI::logger()->notice('Unhandled reason', ['reason' => $notification->reason, 'uri' => $uri]); break; } } @@ -1114,16 +1113,16 @@ function bluesky_fetch_feed(int $uid, string $feed) $languages = $entry->post->record->langs ?? []; if (!Relay::isWantedLanguage($entry->post->record->text, 0, $contact['id'] ?? 0, $languages)) { - Logger::debug('Unwanted language detected', ['languages' => $languages, 'text' => $entry->post->record->text]); + DI::logger()->debug('Unwanted language detected', ['languages' => $languages, 'text' => $entry->post->record->text]); continue; } $causer = DI::atpActor()->getContactByDID($entry->post->author->did, $uid, 0); $uri_id = bluesky_complete_post($entry->post, $uid, Item::PR_TAG, $causer['id'], Conversation::PARCEL_CONNECTOR); if (!empty($uri_id)) { $stored = Post\Category::storeFileByURIId($uri_id, $uid, Post\Category::SUBCRIPTION, $feedname, $feedurl); - Logger::debug('Stored tag subscription for user', ['uri-id' => $uri_id, 'uid' => $uid, 'name' => $feedname, 'url' => $feedurl, 'stored' => $stored]); + DI::logger()->debug('Stored tag subscription for user', ['uri-id' => $uri_id, 'uid' => $uid, 'name' => $feedname, 'url' => $feedurl, 'stored' => $stored]); } else { - Logger::notice('Post not found', ['entry' => $entry]); + DI::logger()->notice('Post not found', ['entry' => $entry]); } if (!empty($entry->reason)) { bluesky_process_reason($entry->reason, DI::atpProcessor()->getUri($entry->post), $uid); diff --git a/bluesky/bluesky_feed.php b/bluesky/bluesky_feed.php index a20ef1b9..e4aa3fdc 100644 --- a/bluesky/bluesky_feed.php +++ b/bluesky/bluesky_feed.php @@ -1,6 +1,6 @@ $argv[1], 'feed' => $argv[2]]); + DI::logger()->debug('Importing feed - start', ['user' => $argv[1], 'feed' => $argv[2]]); bluesky_fetch_feed($argv[1], $argv[2]); - Logger::debug('Importing feed - done', ['user' => $argv[1], 'feed' => $argv[2]]); + DI::logger()->debug('Importing feed - done', ['user' => $argv[1], 'feed' => $argv[2]]); } diff --git a/bluesky/bluesky_notifications.php b/bluesky/bluesky_notifications.php index 1fbc8f67..e1bf2047 100644 --- a/bluesky/bluesky_notifications.php +++ b/bluesky/bluesky_notifications.php @@ -1,6 +1,6 @@ $argv[1]]); + DI::logger()->notice('importing notifications - start', ['user' => $argv[1]]); bluesky_fetch_notifications($argv[1]); - Logger::notice('importing notifications - done', ['user' => $argv[1]]); + DI::logger()->notice('importing notifications - done', ['user' => $argv[1]]); } diff --git a/bluesky/bluesky_timeline.php b/bluesky/bluesky_timeline.php index fda846ba..37b22d99 100644 --- a/bluesky/bluesky_timeline.php +++ b/bluesky/bluesky_timeline.php @@ -1,6 +1,6 @@ $argv[1]]); + DI::logger()->notice('importing timeline - start', ['user' => $argv[1]]); bluesky_fetch_timeline($argv[1]); - Logger::notice('importing timeline - done', ['user' => $argv[1]]); + DI::logger()->notice('importing timeline - done', ['user' => $argv[1]]); } diff --git a/catavatar/catavatar.php b/catavatar/catavatar.php index 2bdf0cca..7b5f05c0 100644 --- a/catavatar/catavatar.php +++ b/catavatar/catavatar.php @@ -7,7 +7,6 @@ */ use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\DI; @@ -27,7 +26,7 @@ function catavatar_install() Hook::register('addon_settings', __FILE__, 'catavatar_addon_settings'); Hook::register('addon_settings_post', __FILE__, 'catavatar_addon_settings_post'); - Logger::notice('registered catavatar'); + DI::logger()->notice('registered catavatar'); } /** diff --git a/cld/cld.php b/cld/cld.php index 83361e2b..d4fef6c5 100644 --- a/cld/cld.php +++ b/cld/cld.php @@ -7,7 +7,6 @@ */ use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\DI; function cld_install() @@ -18,17 +17,17 @@ function cld_install() function cld_detect_languages(array &$data) { if (!in_array('cld2', get_loaded_extensions())) { - Logger::warning('CLD2 is not installed.'); + DI::logger()->warning('CLD2 is not installed.'); return; } if (!class_exists('CLD2Detector')) { - Logger::warning('CLD2Detector class does not exist.'); + DI::logger()->warning('CLD2Detector class does not exist.'); return; } if (!class_exists('CLD2Encoding')) { - Logger::warning('CLD2Encoding class does not exist.'); + DI::logger()->warning('CLD2Encoding class does not exist.'); return; } @@ -53,7 +52,7 @@ function cld_detect_languages(array &$data) } if (!$result['is_reliable']) { - Logger::debug('Unreliable detection', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]); + DI::logger()->debug('Unreliable detection', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]); if (($original == $detected) && ($data['detected'][$original] < $result['language_probability'] / 100)) { $data['detected'][$original] = $result['language_probability'] / 100; } @@ -63,12 +62,12 @@ function cld_detect_languages(array &$data) $available = array_keys(DI::l10n()->getLanguageCodes()); if (!in_array($detected, $available)) { - Logger::debug('Unsupported language', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]); + DI::logger()->debug('Unsupported language', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]); return; } if ($original != $detected) { - Logger::debug('Detected different language', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]); + DI::logger()->debug('Detected different language', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]); } $length = count($data['detected']); diff --git a/diaspora/diaspora.php b/diaspora/diaspora.php index d6c98e34..3c4b4c0e 100644 --- a/diaspora/diaspora.php +++ b/diaspora/diaspora.php @@ -11,7 +11,6 @@ require_once 'addon/diaspora/Diaspora_Connection.php'; use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\Core\Worker; @@ -186,7 +185,7 @@ function diaspora_send(array &$b) { $hostname = DI::baseUrl()->getHost(); - Logger::notice('diaspora_send: invoked'); + DI::logger()->notice('diaspora_send: invoked'); if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) { return; @@ -210,14 +209,14 @@ function diaspora_send(array &$b) return; } - Logger::info('diaspora_send: prepare posting'); + DI::logger()->info('diaspora_send: prepare posting'); $handle = DI::pConfig()->get($b['uid'], 'diaspora', 'handle'); $password = DI::pConfig()->get($b['uid'], 'diaspora', 'password'); $aspect = DI::pConfig()->get($b['uid'], 'diaspora', 'aspect'); if ($handle && $password) { - Logger::info('diaspora_send: all values seem to be okay'); + DI::logger()->info('diaspora_send: all values seem to be okay'); $title = $b['title']; $body = $b['body']; @@ -248,20 +247,20 @@ function diaspora_send(array &$b) require_once "addon/diaspora/diasphp.php"; try { - Logger::info('diaspora_send: prepare'); + DI::logger()->info('diaspora_send: prepare'); $conn = new Diaspora_Connection($handle, $password); - Logger::info('diaspora_send: try to log in ' . $handle); + DI::logger()->info('diaspora_send: try to log in ' . $handle); $conn->logIn(); - Logger::info('diaspora_send: try to send ' . $body); + DI::logger()->info('diaspora_send: try to send ' . $body); $conn->provider = $hostname; $conn->postStatusMessage($body, $aspect); - Logger::notice('diaspora_send: success'); + DI::logger()->notice('diaspora_send: success'); } catch (Exception $e) { - Logger::notice("diaspora_send: Error submitting the post: " . $e->getMessage()); + DI::logger()->notice("diaspora_send: Error submitting the post: " . $e->getMessage()); - Logger::info('diaspora_send: requeueing ' . $b['uid']); + DI::logger()->info('diaspora_send: requeueing ' . $b['uid']); Worker::defer(); } diff --git a/discourse/discourse.php b/discourse/discourse.php index e97a4fd8..b8d0d996 100644 --- a/discourse/discourse.php +++ b/discourse/discourse.php @@ -10,7 +10,6 @@ use Friendica\Content\Text\Markdown; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Database\DBA; @@ -79,13 +78,13 @@ function discourse_email_getmessage(&$message) // We do assume that all Discourse servers are running with SSL if (preg_match('=topic/(.*\d)/(.*\d)@(.*)=', $message['item']['uri'], $matches) && discourse_fetch_post_from_api($message, $matches[2], $matches[3])) { - Logger::info('Fetched comment via API (message-id mode)', ['host' => $matches[3], 'topic' => $matches[1], 'post' => $matches[2]]); + DI::logger()->info('Fetched comment via API (message-id mode)', ['host' => $matches[3], 'topic' => $matches[1], 'post' => $matches[2]]); return; } if (preg_match('=topic/(.*\d)@(.*)=', $message['item']['uri'], $matches) && discourse_fetch_topic_from_api($message, 'https://' . $matches[2], $matches[1], 1)) { - Logger::info('Fetched starting post via API (message-id mode)', ['host' => $matches[2], 'topic' => $matches[1]]); + DI::logger()->info('Fetched starting post via API (message-id mode)', ['host' => $matches[2], 'topic' => $matches[1]]); return; } @@ -95,16 +94,16 @@ function discourse_email_getmessage(&$message) } if (empty($message['item']['plink']) || !preg_match('=(http.*)/t/.*/(.*\d)/(.*\d)=', $message['item']['plink'], $matches)) { - Logger::info('This is no Discourse post'); + DI::logger()->info('This is no Discourse post'); return; } if (discourse_fetch_topic_from_api($message, $matches[1], $matches[2], $matches[3])) { - Logger::info('Fetched post via API (plink mode)', ['host' => $matches[1], 'topic' => $matches[2], 'id' => $matches[3]]); + DI::logger()->info('Fetched post via API (plink mode)', ['host' => $matches[1], 'topic' => $matches[2], 'id' => $matches[3]]); return; } - Logger::info('Fallback mode', ['plink' => $message['item']['plink']]); + DI::logger()->info('Fallback mode', ['plink' => $message['item']['plink']]); // Search in the HTML part for the discourse entry and the author profile if (!empty($message['html'])) { $message = discourse_get_html($message); @@ -121,7 +120,7 @@ function discourse_fetch_post($host, $topic, $pid) $url = $host . '/t/' . $topic . '/' . $pid . '.json'; $curlResult = DI::httpClient()->get($url); if (!$curlResult->isSuccess()) { - Logger::info('No success', ['url' => $url]); + DI::logger()->info('No success', ['url' => $url]); return false; } @@ -133,11 +132,11 @@ function discourse_fetch_post($host, $topic, $pid) /// @todo Possibly fetch missing posts here continue; } - Logger::info('Got post data from topic', $post); + DI::logger()->info('Got post data from topic', $post); return $post; } - Logger::info('Post not found', ['host' => $host, 'topic' => $topic, 'pid' => $pid]); + DI::logger()->info('Post not found', ['host' => $host, 'topic' => $topic, 'pid' => $pid]); return false; } @@ -169,7 +168,7 @@ function discourse_fetch_post_from_api(&$message, $post, $host) $message = discourse_process_post($message, $data, $hostaddr); - Logger::info('Got API data', $message); + DI::logger()->info('Got API data', $message); return true; } @@ -202,7 +201,7 @@ function discourse_get_user($post, $hostaddr) $contact['url'] = $hostaddr . '/u/' . $contact['nick']; $contact['nurl'] = Strings::normaliseLink($contact['url']); $contact['baseurl'] = $hostaddr; - Logger::info('Contact', $contact); + DI::logger()->info('Contact', $contact); $contact['id'] = Contact::getIdForURL($contact['url'], 0, false, $contact); if (!empty($contact['id'])) { $avatar = $contact['photo']; @@ -268,11 +267,11 @@ function discourse_get_html($message) $div = $doc2->importNode($result->item(0), true); $doc2->appendChild($div); $message['html'] = $doc2->saveHTML(); - Logger::info('Found html body', ['html' => $message['html']]); + DI::logger()->info('Found html body', ['html' => $message['html']]); $profile = discourse_get_profile($xpath); if (!empty($profile['url'])) { - Logger::info('Found profile', $profile); + DI::logger()->info('Found profile', $profile); $message['item']['author-id'] = Contact::getIdForURL($profile['url'], 0, false, $profile); $message['item']['author-link'] = $profile['url']; $message['item']['author-name'] = $profile['name']; @@ -288,21 +287,21 @@ function discourse_get_text($message) $text = str_replace("\r", '', $text); $pos = strpos($text, "\n---\n"); if ($pos == 0) { - Logger::info('No separator found', ['text' => $text]); + DI::logger()->info('No separator found', ['text' => $text]); return $message; } $message['text'] = trim(substr($text, 0, $pos)); - Logger::info('Found text body', ['text' => $message['text']]); + DI::logger()->info('Found text body', ['text' => $message['text']]); $message['text'] = Markdown::toBBCode($message['text']); $text = substr($text, $pos); - Logger::info('Found footer', ['text' => $text]); + DI::logger()->info('Found footer', ['text' => $text]); if (preg_match('=\((http.*/t/.*/.*\d/.*\d)\)=', $text, $link)) { $message['item']['plink'] = $link[1]; - Logger::info('Found plink', ['plink' => $message['item']['plink']]); + DI::logger()->info('Found plink', ['plink' => $message['item']['plink']]); } return $message; } diff --git a/dwpost/dwpost.php b/dwpost/dwpost.php index 7ce30086..7bad85dc 100644 --- a/dwpost/dwpost.php +++ b/dwpost/dwpost.php @@ -10,7 +10,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Model\Item; @@ -185,12 +184,12 @@ function dwpost_send(array &$b) EOT; - Logger::debug('dwpost: data: ' . $xml); + DI::logger()->debug('dwpost: data: ' . $xml); if ($dw_blog !== 'test') { $x = DI::httpClient()->post($dw_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString(); } - Logger::info('posted to dreamwidth: ' . ($x) ? $x : ''); + DI::logger()->info('posted to dreamwidth: ' . ($x) ? $x : ''); } } diff --git a/fromapp/fromapp.php b/fromapp/fromapp.php index 8bd27606..bb8a4fe6 100644 --- a/fromapp/fromapp.php +++ b/fromapp/fromapp.php @@ -8,7 +8,6 @@ */ use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; @@ -17,7 +16,7 @@ function fromapp_install() Hook::register('post_local', 'addon/fromapp/fromapp.php', 'fromapp_post_hook'); Hook::register('addon_settings', 'addon/fromapp/fromapp.php', 'fromapp_settings'); Hook::register('addon_settings_post', 'addon/fromapp/fromapp.php', 'fromapp_settings_post'); - Logger::notice("installed fromapp"); + DI::logger()->notice("installed fromapp"); } function fromapp_settings_post($post) diff --git a/geocoordinates/geocoordinates.php b/geocoordinates/geocoordinates.php index eb56f093..5af1defc 100644 --- a/geocoordinates/geocoordinates.php +++ b/geocoordinates/geocoordinates.php @@ -7,7 +7,6 @@ */ use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; @@ -51,25 +50,25 @@ function geocoordinates_resolve_item(array &$item) $s = DI::httpClient()->fetch('https://api.opencagedata.com/geocode/v1/json?q=' . $coords[0] . ',' . $coords[1] . '&key=' . $key . '&language=' . $language); if (!$s) { - Logger::info('API could not be queried'); + DI::logger()->info('API could not be queried'); return; } $data = json_decode($s); if ($data->status->code != '200') { - Logger::info('API returned error ' . $data->status->code . ' ' . $data->status->message); + DI::logger()->info('API returned error ' . $data->status->code . ' ' . $data->status->message); return; } if (($data->total_results == 0) || (count($data->results) == 0)) { - Logger::info('No results found for coordinates ' . $item['coord']); + DI::logger()->info('No results found for coordinates ' . $item['coord']); return; } $item['location'] = $data->results[0]->formatted; - Logger::info('Got location for coordinates ' . $coords[0] . '-' . $coords[1] . ': ' . $item['location']); + DI::logger()->info('Got location for coordinates ' . $coords[0] . '-' . $coords[1] . ': ' . $item['location']); if ($item['location'] != '') { DI::cache()->set('geocoordinates:' . $language.':' . $coords[0] . '-' . $coords[1], $item['location']); diff --git a/geonames/geonames.php b/geonames/geonames.php index d14b1e8f..4c5e54d8 100644 --- a/geonames/geonames.php +++ b/geonames/geonames.php @@ -7,7 +7,6 @@ */ use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Core\Config\Util\ConfigFileManager; @@ -45,7 +44,7 @@ function geonames_post_hook(array &$item) * - The profile owner must have allowed our addon */ - Logger::notice('geonames invoked'); + DI::logger()->notice('geonames invoked'); if (!DI::userSession()->getLocalUserId()) { /* non-zero if this is a logged in user of this system */ return; diff --git a/gnot/gnot.php b/gnot/gnot.php index 5d0919cb..3801a210 100644 --- a/gnot/gnot.php +++ b/gnot/gnot.php @@ -9,7 +9,6 @@ */ use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Model\Notification; @@ -20,7 +19,7 @@ function gnot_install() Hook::register('addon_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post'); Hook::register('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail'); - Logger::notice("installed gnot"); + DI::logger()->notice("installed gnot"); } /** diff --git a/googlemaps/googlemaps.php b/googlemaps/googlemaps.php index b83a9cf9..94a3a96b 100644 --- a/googlemaps/googlemaps.php +++ b/googlemaps/googlemaps.php @@ -8,13 +8,13 @@ */ use Friendica\Core\Hook; -use Friendica\Core\Logger; +use Friendica\DI; function googlemaps_install() { Hook::register('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location'); - Logger::notice('installed googlemaps'); + DI::logger()->notice('installed googlemaps'); } function googlemaps_location(&$item) diff --git a/gravatar/gravatar.php b/gravatar/gravatar.php index 6007c433..7fe0d955 100644 --- a/gravatar/gravatar.php +++ b/gravatar/gravatar.php @@ -8,7 +8,6 @@ use Friendica\BaseModule; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Core\Config\Util\ConfigFileManager; @@ -20,7 +19,7 @@ function gravatar_install() { Hook::register('load_config', 'addon/gravatar/gravatar.php', 'gravatar_load_config'); Hook::register('avatar_lookup', 'addon/gravatar/gravatar.php', 'gravatar_lookup'); - Logger::notice("registered gravatar in avatar_lookup hook"); + DI::logger()->notice("registered gravatar in avatar_lookup hook"); } function gravatar_load_config(ConfigFileManager $loader) diff --git a/ifttt/ifttt.php b/ifttt/ifttt.php index 51fa8db8..cb23032b 100644 --- a/ifttt/ifttt.php +++ b/ifttt/ifttt.php @@ -8,7 +8,6 @@ */ use Friendica\Content\PageInfo; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Core\Worker; use Friendica\Database\DBA; @@ -86,16 +85,16 @@ function ifttt_post() $user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname]); if (!DBA::isResult($user)) { - Logger::info('User ' . $nickname . ' not found.'); + DI::logger()->info('User ' . $nickname . ' not found.'); return; } $uid = $user['uid']; - Logger::info('Received a post for user ' . $uid . ' from ifttt ' . print_r($_REQUEST, true)); + DI::logger()->info('Received a post for user ' . $uid . ' from ifttt ' . print_r($_REQUEST, true)); if (!isset($_REQUEST['key'])) { - Logger::notice('No key found.'); + DI::logger()->notice('No key found.'); return; } @@ -103,7 +102,7 @@ function ifttt_post() // Check the key if ($key != DI::pConfig()->get($uid, 'ifttt', 'key')) { - Logger::info('Invalid key for user ' . $uid); + DI::logger()->info('Invalid key for user ' . $uid); return; } @@ -114,7 +113,7 @@ function ifttt_post() } if (!in_array($item['type'], ['status', 'link', 'photo'])) { - Logger::info('Unknown item type ' . $item['type']); + DI::logger()->info('Unknown item type ' . $item['type']); return; } diff --git a/ijpost/ijpost.php b/ijpost/ijpost.php index 37c3cd45..9fe502af 100644 --- a/ijpost/ijpost.php +++ b/ijpost/ijpost.php @@ -10,7 +10,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Model\Item; @@ -178,11 +177,11 @@ function ijpost_send(array &$b) EOT; - Logger::debug('ijpost: data: ' . $xml); + DI::logger()->debug('ijpost: data: ' . $xml); if ($ij_blog !== 'test') { $x = DI::httpClient()->post($ij_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString(); } - Logger::info('posted to insanejournal: ' . $x ? $x : ''); + DI::logger()->info('posted to insanejournal: ' . $x ? $x : ''); } } diff --git a/impressum/impressum.php b/impressum/impressum.php index f61d7182..0ad34e40 100644 --- a/impressum/impressum.php +++ b/impressum/impressum.php @@ -9,7 +9,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Core\Config\Util\ConfigFileManager; @@ -20,7 +19,7 @@ function impressum_install() Hook::register('load_config', 'addon/impressum/impressum.php', 'impressum_load_config'); Hook::register('about_hook', 'addon/impressum/impressum.php', 'impressum_show'); Hook::register('page_end', 'addon/impressum/impressum.php', 'impressum_footer'); - Logger::notice("installed impressum Addon"); + DI::logger()->notice("installed impressum Addon"); } /** diff --git a/js_upload/js_upload.php b/js_upload/js_upload.php index f1d85aa3..c0a2467d 100644 --- a/js_upload/js_upload.php +++ b/js_upload/js_upload.php @@ -8,7 +8,6 @@ */ use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Util\Images; @@ -68,7 +67,7 @@ function js_upload_post_init(array &$b) $js_upload_jsonresponse = htmlspecialchars(json_encode($result), ENT_NOQUOTES); if (isset($result['error'])) { - Logger::info('mod/photos.php: photos_post(): error uploading photo: ' . $result['error']); + DI::logger()->info('mod/photos.php: photos_post(): error uploading photo: ' . $result['error']); echo json_encode($result); exit(); } @@ -91,7 +90,7 @@ function js_upload_post_end(int &$b) { global $js_upload_jsonresponse; - Logger::notice('upload_post_end'); + DI::logger()->notice('upload_post_end'); if (!empty($js_upload_jsonresponse)) { echo $js_upload_jsonresponse; exit(); @@ -187,6 +186,10 @@ class js_upload_qqFileUploader { private $allowedExtensions; private $sizeLimit; + + /** + * @var js_upload_qqUploadedFileXhr|js_upload_qqUploadedFileForm + */ private $file; function __construct(array $allowedExtensions = [], $sizeLimit) @@ -234,7 +237,7 @@ class js_upload_qqFileUploader $filename = $pathinfo['filename']; if (!isset($pathinfo['extension'])) { - Logger::warning('extension isn\'t set.', ['filename' => $filename]); + DI::logger()->warning('extension isn\'t set.', ['filename' => $filename]); } $ext = $pathinfo['extension'] ?? ''; diff --git a/keycloakpassword/keycloakpassword.php b/keycloakpassword/keycloakpassword.php index e9809f86..11034ffe 100644 --- a/keycloakpassword/keycloakpassword.php +++ b/keycloakpassword/keycloakpassword.php @@ -7,7 +7,6 @@ */ use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\DI; @@ -37,7 +36,7 @@ function keycloakpassword_request($client_id, $secret, $url, $params = []) $res = curl_exec($ch); if (curl_errno($ch)) { - Logger::error(curl_error($ch)); + DI::logger()->error(curl_error($ch)); } curl_close($ch); diff --git a/krynn/krynn.php b/krynn/krynn.php index fa9db133..b57d827e 100644 --- a/krynn/krynn.php +++ b/krynn/krynn.php @@ -11,7 +11,6 @@ */ use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; @@ -31,7 +30,7 @@ function krynn_install() Hook::register('addon_settings', 'addon/krynn/krynn.php', 'krynn_settings'); Hook::register('addon_settings_post', 'addon/krynn/krynn.php', 'krynn_settings_post'); - Logger::notice("installed krynn"); + DI::logger()->notice("installed krynn"); } function krynn_post_hook(&$item) diff --git a/ldapauth/ldapauth.php b/ldapauth/ldapauth.php index f834b4d5..b80c5226 100644 --- a/ldapauth/ldapauth.php +++ b/ldapauth/ldapauth.php @@ -30,7 +30,6 @@ */ use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\User; @@ -69,54 +68,54 @@ function ldapauth_authenticate($username, $password) $ldap_autocreateaccount_nameattribute = DI::config()->get('ldapauth', 'ldap_autocreateaccount_nameattribute'); if (!extension_loaded('ldap') || !strlen($ldap_server)) { - Logger::error('Addon not configured or missing php-ldap extension', ['extension_loaded' => extension_loaded('ldap'), 'server' => $ldap_server]); + DI::logger()->error('Addon not configured or missing php-ldap extension', ['extension_loaded' => extension_loaded('ldap'), 'server' => $ldap_server]); return false; } if (!strlen($password)) { - Logger::error('Empty password disallowed', ['provided_password_length' => strlen($password)]); + DI::logger()->error('Empty password disallowed', ['provided_password_length' => strlen($password)]); return false; } $connect = @ldap_connect($ldap_server); if ($connect === false) { - Logger::warning('Could not connect to LDAP server', ['server' => $ldap_server]); + DI::logger()->warning('Could not connect to LDAP server', ['server' => $ldap_server]); return false; } @ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3); @ldap_set_option($connect, LDAP_OPT_REFERRALS, 0); if ((@ldap_bind($connect, $ldap_binddn, $ldap_bindpw)) === false) { - Logger::warning('Could not bind to LDAP server', ['server' => $ldap_server, 'binddn' => $ldap_binddn, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]); + DI::logger()->warning('Could not bind to LDAP server', ['server' => $ldap_server, 'binddn' => $ldap_binddn, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]); return false; } $res = @ldap_search($connect, $ldap_searchdn, $ldap_userattr . '=' . $username); if (!$res) { - Logger::notice('LDAP user not found.', ['searchdn' => $ldap_searchdn, 'userattr' => $ldap_userattr, 'username' => $username, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]); + DI::logger()->notice('LDAP user not found.', ['searchdn' => $ldap_searchdn, 'userattr' => $ldap_userattr, 'username' => $username, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]); return false; } $id = @ldap_first_entry($connect, $res); if (!$id) { - Logger::notice('Could not retrieve first LDAP entry.', ['searchdn' => $ldap_searchdn, 'userattr' => $ldap_userattr, 'username' => $username, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]); + DI::logger()->notice('Could not retrieve first LDAP entry.', ['searchdn' => $ldap_searchdn, 'userattr' => $ldap_userattr, 'username' => $username, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]); return false; } $dn = @ldap_get_dn($connect, $id); if (!@ldap_bind($connect, $dn, $password)) { - Logger::notice('Could not authenticate LDAP user with provided password', ['errno' => ldap_errno($connect), 'error' => ldap_error($connect)]); + DI::logger()->notice('Could not authenticate LDAP user with provided password', ['errno' => ldap_errno($connect), 'error' => ldap_error($connect)]); return false; } if (strlen($ldap_group) && @ldap_compare($connect, $ldap_group, 'member', $dn) !== true) { $errno = @ldap_errno($connect); if ($errno === 32) { - Logger::notice('LDAP Access Control Group does not exist', ['errno' => $errno, 'error' => ldap_error($connect)]); + DI::logger()->notice('LDAP Access Control Group does not exist', ['errno' => $errno, 'error' => ldap_error($connect)]); } elseif ($errno === 16) { - Logger::notice('LDAP membership attribute does not exist in access control group', ['errno' => $errno, 'error' => ldap_error($connect)]); + DI::logger()->notice('LDAP membership attribute does not exist in access control group', ['errno' => $errno, 'error' => ldap_error($connect)]); } else { - Logger::notice('LDAP user isn\'t part of the authorized group', ['dn' => $dn]); + DI::logger()->notice('LDAP user isn\'t part of the authorized group', ['dn' => $dn]); } @ldap_close($connect); @@ -140,7 +139,7 @@ function ldapauth_authenticate($username, $password) $authentication = User::getAuthenticationInfo($username); return User::getById($authentication['uid']); } catch (Exception $e) { - Logger::notice('LDAP authentication error: ' . $e->getMessage()); + DI::logger()->notice('LDAP authentication error: ' . $e->getMessage()); return false; } } @@ -148,7 +147,7 @@ function ldapauth_authenticate($username, $password) function ldap_createaccount($username, $password, $email, $name) { if (!strlen($email) || !strlen($name)) { - Logger::notice('Could not create local user from LDAP data, no email or nickname provided'); + DI::logger()->notice('Could not create local user from LDAP data, no email or nickname provided'); return false; } @@ -160,10 +159,10 @@ function ldap_createaccount($username, $password, $email, $name) 'password' => $password, 'verified' => 1 ]); - Logger::info('Local user created from LDAP data', ['username' => $username, 'name' => $name]); + DI::logger()->info('Local user created from LDAP data', ['username' => $username, 'name' => $name]); return $user; } catch (Exception $ex) { - Logger::error('Could not create local user from LDAP data', ['username' => $username, 'exception' => $ex->getMessage()]); + DI::logger()->error('Could not create local user from LDAP data', ['username' => $username, 'exception' => $ex->getMessage()]); } return false; diff --git a/leistungsschutzrecht/leistungsschutzrecht.php b/leistungsschutzrecht/leistungsschutzrecht.php index ec8091ac..891cb6ca 100644 --- a/leistungsschutzrecht/leistungsschutzrecht.php +++ b/leistungsschutzrecht/leistungsschutzrecht.php @@ -7,7 +7,6 @@ */ use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\DI; function leistungsschutzrecht_install() @@ -168,7 +167,7 @@ function leistungsschutzrecht_cron($b) if ($last) { $next = $last + 86400; if ($next > time()) { - Logger::notice('poll intervall not reached'); + DI::logger()->notice('poll intervall not reached'); return; } } diff --git a/libertree/libertree.php b/libertree/libertree.php index c138e597..1489a029 100644 --- a/libertree/libertree.php +++ b/libertree/libertree.php @@ -8,7 +8,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\DI; @@ -130,7 +129,7 @@ function libertree_post_local(array &$b) function libertree_send(array &$b) { - Logger::notice('libertree_send: invoked'); + DI::logger()->notice('libertree_send: invoked'); if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) { return; @@ -196,6 +195,6 @@ function libertree_send(array &$b) ]; $result = DI::httpClient()->post($ltree_blog, $params)->getBodyString(); - Logger::notice('libertree: ' . $result); + DI::logger()->notice('libertree: ' . $result); } } diff --git a/libravatar/libravatar.php b/libravatar/libravatar.php index 4cd72c83..6cb35331 100644 --- a/libravatar/libravatar.php +++ b/libravatar/libravatar.php @@ -8,7 +8,6 @@ use Friendica\Core\Addon; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Core\Config\Util\ConfigFileManager; @@ -20,7 +19,7 @@ function libravatar_install() { Hook::register('load_config', 'addon/libravatar/libravatar.php', 'libravatar_load_config'); Hook::register('avatar_lookup', 'addon/libravatar/libravatar.php', 'libravatar_lookup'); - Logger::notice("registered libravatar in avatar_lookup hook"); + DI::logger()->notice("registered libravatar in avatar_lookup hook"); } function libravatar_load_config(ConfigFileManager $loader) diff --git a/ljpost/ljpost.php b/ljpost/ljpost.php index b416c605..fd7d1bd8 100644 --- a/ljpost/ljpost.php +++ b/ljpost/ljpost.php @@ -10,7 +10,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Model\Item; @@ -200,7 +199,7 @@ function ljpost_send(array &$b) EOT; - Logger::debug('ljpost: data: ' . $xml); + DI::logger()->debug('ljpost: data: ' . $xml); $x = ''; @@ -208,6 +207,6 @@ EOT; $x = DI::httpClient()->post($lj_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString(); } - Logger::info('posted to livejournal: ' . $x); + DI::logger()->info('posted to livejournal: ' . $x); } } diff --git a/mailstream/mailstream.php b/mailstream/mailstream.php index 9910a63d..5228b168 100644 --- a/mailstream/mailstream.php +++ b/mailstream/mailstream.php @@ -8,7 +8,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Core\Worker; @@ -32,7 +31,7 @@ function mailstream_install() Hook::register('post_remote_end', 'addon/mailstream/mailstream.php', 'mailstream_post_hook'); Hook::register('mailstream_send_hook', 'addon/mailstream/mailstream.php', 'mailstream_send_hook'); - Logger::info("installed mailstream"); + DI::logger()->info("installed mailstream"); } /** @@ -86,7 +85,7 @@ function mailstream_generate_id(string $uri): string $host = DI::baseUrl()->getHost(); $resource = hash('md5', $uri); $message_id = "<" . $resource . "@" . $host . ">"; - Logger::debug('generated message ID', ['id' => $message_id, 'uri' => $uri]); + DI::logger()->debug('generated message ID', ['id' => $message_id, 'uri' => $uri]); return $message_id; } @@ -95,20 +94,20 @@ function mailstream_send_hook(array $data) $criteria = array('uid' => $data['uid'], 'contact-id' => $data['contact-id'], 'uri' => $data['uri']); $item = Post::selectFirst([], $criteria); if (empty($item)) { - Logger::error('could not find item'); + DI::logger()->error('could not find item'); return; } $user = User::getById($item['uid']); if (empty($user)) { - Logger::error('could not find user', ['uid' => $item['uid']]); + DI::logger()->error('could not find user', ['uid' => $item['uid']]); return; } if (!mailstream_send($data['message_id'], $item, $user)) { - Logger::debug('send failed, will retry', $data); + DI::logger()->debug('send failed, will retry', $data); if (!Worker::defer()) { - Logger::error('failed and could not defer', $data); + DI::logger()->error('failed and could not defer', $data); } } } @@ -124,32 +123,32 @@ function mailstream_send_hook(array $data) function mailstream_post_hook(array &$item) { if ($item['uid'] === 0) { - Logger::debug('mailstream: root user, skipping item ' . $item['id']); + DI::logger()->debug('mailstream: root user, skipping item ' . $item['id']); return; } if (!DI::pConfig()->get($item['uid'], 'mailstream', 'enabled')) { - Logger::debug('mailstream: not enabled.', ['item' => $item['id'], ' uid ' => $item['uid']]); + DI::logger()->debug('mailstream: not enabled.', ['item' => $item['id'], ' uid ' => $item['uid']]); return; } if (!$item['contact-id']) { - Logger::debug('no contact-id', ['item' => $item['id']]); + DI::logger()->debug('no contact-id', ['item' => $item['id']]); return; } if (!$item['uri']) { - Logger::debug('no uri', ['item' => $item['id']]); + DI::logger()->debug('no uri', ['item' => $item['id']]); return; } if ($item['verb'] == Activity::ANNOUNCE) { - Logger::debug('ignoring announce', ['item' => $item['id']]); + DI::logger()->debug('ignoring announce', ['item' => $item['id']]); return; } if (DI::pConfig()->get($item['uid'], 'mailstream', 'nolikes')) { if ($item['verb'] == Activity::LIKE) { - Logger::debug('ignoring like', ['item' => $item['id']]); + DI::logger()->debug('ignoring like', ['item' => $item['id']]); return; } if ($item['verb'] == Activity::DISLIKE) { - Logger::debug('ignoring dislike', ['item' => $item['id']]); + DI::logger()->debug('ignoring dislike', ['item' => $item['id']]); return; } } @@ -200,7 +199,7 @@ function mailstream_do_images(array &$item, array &$attachments) try { $curlResult = DI::httpClient()->get($url, HttpClientAccept::DEFAULT, [HttpClientOptions::COOKIEJAR => $cookiejar]); if (!$curlResult->isSuccess()) { - Logger::debug('mailstream: fetch image url failed', [ + DI::logger()->debug('mailstream: fetch image url failed', [ 'url' => $url, 'item_id' => $item['id'], 'return_code' => $curlResult->getReturnCode() @@ -208,7 +207,7 @@ function mailstream_do_images(array &$item, array &$attachments) continue; } } catch (InvalidArgumentException $e) { - Logger::error('exception fetching url', ['url' => $url, 'item_id' => $item['id']]); + DI::logger()->error('exception fetching url', ['url' => $url, 'item_id' => $item['id']]); continue; } $attachments[$url] = [ @@ -309,7 +308,7 @@ function mailstream_subject(array $item): string } $contact = Contact::selectFirst([], ['id' => $item['contact-id'], 'uid' => $item['uid']]); if (!DBA::isResult($contact)) { - Logger::error('no contact', [ + DI::logger()->error('no contact', [ 'item' => $item['id'], 'plink' => $item['plink'], 'contact id' => $item['contact-id'], @@ -351,16 +350,16 @@ function mailstream_subject(array $item): string function mailstream_send(string $message_id, array $item, array $user): bool { if (!is_array($item)) { - Logger::error('item is empty', ['message_id' => $message_id]); + DI::logger()->error('item is empty', ['message_id' => $message_id]); return false; } if (!$item['visible']) { - Logger::debug('item not yet visible', ['item uri' => $item['uri']]); + DI::logger()->debug('item not yet visible', ['item uri' => $item['uri']]); return false; } if (!$message_id) { - Logger::error('no message ID supplied', ['item uri' => $item['uri'], 'user email' => $user['email']]); + DI::logger()->error('no message ID supplied', ['item uri' => $item['uri'], 'user email' => $user['email']]); return true; } @@ -418,15 +417,15 @@ function mailstream_send(string $message_id, array $item, array $user): bool if (!$mail->Send()) { throw new Exception($mail->ErrorInfo); } - Logger::debug('sent message', [ + DI::logger()->debug('sent message', [ 'message ID' => $mail->MessageID, 'subject' => $mail->Subject, 'address' => $address ]); } catch (phpmailerException $e) { - Logger::debug('PHPMailer exception sending message', ['id' => $message_id, 'error' => $e->errorMessage()]); + DI::logger()->debug('PHPMailer exception sending message', ['id' => $message_id, 'error' => $e->errorMessage()]); } catch (Exception $e) { - Logger::debug('exception sending message', ['id' => $message_id, 'error' => $e->getMessage()]); + DI::logger()->debug('exception sending message', ['id' => $message_id, 'error' => $e->getMessage()]); } return true; diff --git a/newmemberwidget/newmemberwidget.php b/newmemberwidget/newmemberwidget.php index d3b68807..ba7dfb39 100644 --- a/newmemberwidget/newmemberwidget.php +++ b/newmemberwidget/newmemberwidget.php @@ -8,7 +8,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Model\User; @@ -16,7 +15,7 @@ use Friendica\Model\User; function newmemberwidget_install() { Hook::register( 'network_mod_init', 'addon/newmemberwidget/newmemberwidget.php', 'newmemberwidget_network_mod_init'); - Logger::notice('newmemberwidget installed'); + DI::logger()->notice('newmemberwidget installed'); } function newmemberwidget_network_mod_init ($b) diff --git a/nominatim/nominatim.php b/nominatim/nominatim.php index a3d14af5..3a567b7b 100644 --- a/nominatim/nominatim.php +++ b/nominatim/nominatim.php @@ -7,7 +7,6 @@ */ use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; @@ -45,19 +44,19 @@ function nominatim_resolve_item(array &$item) $s = DI::httpClient()->fetch('https://nominatim.openstreetmap.org/reverse?lat=' . $coords[0] . '&lon=' . $coords[1] . '&format=json&addressdetails=0&accept-language=' . $language); if (empty($s)) { - Logger::info('API could not be queried'); + DI::logger()->info('API could not be queried'); return; } $data = json_decode($s, true); if (empty($data['display_name'])) { - Logger::info('No results found for coordinates', ['coordinates' => $item['coord'], 'data' => $data]); + DI::logger()->info('No results found for coordinates', ['coordinates' => $item['coord'], 'data' => $data]); return; } $item['location'] = $data['display_name']; - Logger::info('Got location', ['lat' => $coords[0], 'long' => $coords[1], 'location' => $item['location']]); + DI::logger()->info('Got location', ['lat' => $coords[0], 'long' => $coords[1], 'location' => $item['location']]); if (!empty($item['location'])) { DI::cache()->set('nominatim:' . $language . ':' . $coords[0] . '-' . $coords[1], $item['location']); diff --git a/numfriends/numfriends.php b/numfriends/numfriends.php index 66c9b74a..5652c8f0 100644 --- a/numfriends/numfriends.php +++ b/numfriends/numfriends.php @@ -7,7 +7,6 @@ */ use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; @@ -16,7 +15,7 @@ function numfriends_install() { Hook::register('addon_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings'); Hook::register('addon_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post'); - Logger::notice("installed numfriends"); + DI::logger()->notice("installed numfriends"); } /** diff --git a/openstreetmap/openstreetmap.php b/openstreetmap/openstreetmap.php index fc5ebbbe..bf0f54b6 100644 --- a/openstreetmap/openstreetmap.php +++ b/openstreetmap/openstreetmap.php @@ -11,7 +11,6 @@ use Friendica\Core\Cache\Enum\Duration; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Core\Config\Util\ConfigFileManager; @@ -31,7 +30,7 @@ function openstreetmap_install() Hook::register('Map::getCoordinates', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_get_coordinates'); Hook::register('page_header', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_alterheader'); - Logger::notice("installed openstreetmap"); + DI::logger()->notice("installed openstreetmap"); } function openstreetmap_load_config(ConfigFileManager $loader) @@ -154,8 +153,8 @@ function openstreetmap_generate_map(array &$b) $lat = $b['lat']; // round($b['lat'], 5); $lon = $b['lon']; // round($b['lon'], 5); - Logger::debug('lat: ' . $lat); - Logger::debug('lon: ' . $lon); + DI::logger()->debug('lat: ' . $lat); + DI::logger()->debug('lon: ' . $lon); $cardlink = 'notice("installed piwik addon"); } function piwik_load_config(ConfigFileManager $loader) diff --git a/planets/planets.php b/planets/planets.php index d96e33a6..8849010a 100644 --- a/planets/planets.php +++ b/planets/planets.php @@ -8,7 +8,6 @@ */ use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; @@ -28,7 +27,7 @@ function planets_install() Hook::register('addon_settings', 'addon/planets/planets.php', 'planets_settings'); Hook::register('addon_settings_post', 'addon/planets/planets.php', 'planets_settings_post'); - Logger::notice("installed planets"); + DI::logger()->notice("installed planets"); } /** @@ -39,7 +38,7 @@ function planets_install() */ function planets_post_hook(&$item) { - Logger::notice('planets invoked'); + DI::logger()->notice('planets invoked'); if (!DI::userSession()->getLocalUserId()) { /* non-zero if this is a logged in user of this system */ diff --git a/pnut/pnut.php b/pnut/pnut.php index f298997b..5460b991 100644 --- a/pnut/pnut.php +++ b/pnut/pnut.php @@ -14,7 +14,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Content\Text\Plaintext; use Friendica\Core\Config\Util\ConfigFileManager; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\DI; @@ -76,7 +75,7 @@ function pnut_connect() try { $token = $nut->getAccessToken($callback_url); - Logger::debug('Got Token', [$token]); + DI::logger()->debug('Got Token', [$token]); $o = DI::l10n()->t('You are now authenticated with pnut.io.'); DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pnut', 'access_token', $token); } catch (phpnutException $e) { @@ -266,8 +265,8 @@ function pnut_post_hook(array &$b) return; } - Logger::notice('PNUT post invoked', ['id' => $b['id'], 'guid' => $b['guid'], 'plink' => $b['plink']]); - Logger::debug('PNUT array', $b); + DI::logger()->notice('PNUT post invoked', ['id' => $b['id'], 'guid' => $b['guid'], 'plink' => $b['plink']]); + DI::logger()->debug('PNUT array', $b); $token = DI::pConfig()->get($b['uid'], 'pnut', 'access_token'); $nut = new phpnut\phpnut($token); @@ -276,7 +275,7 @@ function pnut_post_hook(array &$b) $text = $msgarr['text']; $raw = []; - Logger::debug('PNUT msgarr', $msgarr); + DI::logger()->debug('PNUT msgarr', $msgarr); if (count($msgarr['parts']) > 1) { $tstamp = time(); @@ -292,23 +291,23 @@ function pnut_post_hook(array &$b) if ($msgarr['type'] == 'photo') { $fileraw = ['type' => 'dev.mcmillian.friendica.image', 'kind' => 'image', 'is_public' => true]; foreach ($msgarr['images'] as $image) { - Logger::debug('PNUT image', $image); + DI::logger()->debug('PNUT image', $image); if (!empty($image['id'])) { $photo = Photo::selectFirst([], ['id' => $image['id']]); - Logger::debug('PNUT selectFirst'); + DI::logger()->debug('PNUT selectFirst'); } else { $photo = Photo::createPhotoForExternalResource($image['url']); - Logger::debug('PNUT createPhotoForExternalResource'); + DI::logger()->debug('PNUT createPhotoForExternalResource'); } $picturedata = Photo::getImageForPhoto($photo); - Logger::debug('PNUT photo', $photo); + DI::logger()->debug('PNUT photo', $photo); $picurefile = tempnam(System::getTempPath(), 'pnut'); file_put_contents($picurefile, $picturedata); - Logger::debug('PNUT got file?', ['filename' => $picurefile]); + DI::logger()->debug('PNUT got file?', ['filename' => $picurefile]); $imagefile = $nut->createFile($picurefile, $fileraw); - Logger::debug('PNUT file', ['pnutimagefile' => $imagefile]); + DI::logger()->debug('PNUT file', ['pnutimagefile' => $imagefile]); unlink($picurefile); $raw['io.pnut.core.oembed'][] = ['+io.pnut.core.file' => ['file_id' => $imagefile['id'], 'file_token' => $imagefile['file_token'], 'format' => 'oembed']]; @@ -318,5 +317,5 @@ function pnut_post_hook(array &$b) $raw['io.pnut.core.crosspost'][] = ['canonical_url' => $b['plink']]; $nut->createPost($text, ['raw' => $raw]); - Logger::debug('PNUT post complete', ['id' => $b['id'], 'text' => $text, 'raw' => $raw]); + DI::logger()->debug('PNUT post complete', ['id' => $b['id'], 'text' => $text, 'raw' => $raw]); } diff --git a/public_server/public_server.php b/public_server/public_server.php index eb7af1e7..9cd0f667 100644 --- a/public_server/public_server.php +++ b/public_server/public_server.php @@ -8,7 +8,6 @@ use Friendica\BaseModule; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\DI; @@ -47,7 +46,7 @@ function public_server_register_account($b) function public_server_cron($b) { - Logger::notice("public_server: cron start"); + DI::logger()->notice("public_server: cron start"); $users = DBA::selectToArray('user', [], ["`account_expires_on` > ? AND `account_expires_on` < ? AND `expire_notification_sent` <= ?", DBA::NULL_DATETIME, DateTimeFormat::utc('now + 5 days'), DBA::NULL_DATETIME]); @@ -96,7 +95,7 @@ function public_server_cron($b) } } - Logger::notice("public_server: cron end"); + DI::logger()->notice("public_server: cron end"); } function public_server_enotify(array &$b) diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index ffe5f187..c3445b48 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -10,7 +10,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Content\Text\HTML; use Friendica\Core\Addon; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Core\Worker; @@ -107,7 +106,7 @@ function pumpio_registerclient($host) $params['logo_url'] = DI::baseUrl() . '/images/friendica-256.png'; $params['redirect_uris'] = DI::baseUrl() . '/pumpio/connect'; - Logger::info('pumpio_registerclient: ' . $url . ' parameters', $params); + DI::logger()->info('pumpio_registerclient: ' . $url . ' parameters', $params); // @TODO Rewrite this to our own HTTP client $ch = curl_init($url); @@ -122,10 +121,10 @@ function pumpio_registerclient($host) if ($curl_info['http_code'] == '200') { $values = json_decode($s); - Logger::info('pumpio_registerclient: success ', (array)$values); + DI::logger()->info('pumpio_registerclient: success ', (array)$values); return $values; } - Logger::info('pumpio_registerclient: failed: ', $curl_info); + DI::logger()->info('pumpio_registerclient: failed: ', $curl_info); return false; } @@ -138,7 +137,7 @@ function pumpio_connect() $hostname = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'host'); if ((($consumer_key == '') || ($consumer_secret == '')) && ($hostname != '')) { - Logger::notice('pumpio_connect: register client'); + DI::logger()->notice('pumpio_connect: register client'); $clientdata = pumpio_registerclient($hostname); DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_key', $clientdata->client_id); DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_secret', $clientdata->client_secret); @@ -146,11 +145,11 @@ function pumpio_connect() $consumer_key = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_key'); $consumer_secret = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_secret'); - Logger::info('pumpio_connect: ckey: ' . $consumer_key . ' csecrect: ' . $consumer_secret); + DI::logger()->info('pumpio_connect: ckey: ' . $consumer_key . ' csecrect: ' . $consumer_secret); } if (($consumer_key == '') || ($consumer_secret == '')) { - Logger::notice('pumpio_connect: '.sprintf('Unable to register the client at the pump.io server "%s".', $hostname)); + DI::logger()->notice('pumpio_connect: '.sprintf('Unable to register the client at the pump.io server "%s".', $hostname)); return DI::l10n()->t("Unable to register the client at the pump.io server '%s'.", $hostname); } @@ -179,7 +178,7 @@ function pumpio_connect() if (($success = $client->Initialize())) { if (($success = $client->Process())) { if (strlen($client->access_token)) { - Logger::info('pumpio_connect: otoken: ' . $client->access_token . ', osecrect: ' . $client->access_token_secret); + DI::logger()->info('pumpio_connect: otoken: ' . $client->access_token . ', osecrect: ' . $client->access_token_secret); DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'oauth_token', $client->access_token); DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'oauth_token_secret', $client->access_token_secret); } @@ -191,11 +190,11 @@ function pumpio_connect() } if ($success) { - Logger::notice('pumpio_connect: authenticated'); + DI::logger()->notice('pumpio_connect: authenticated'); $o = DI::l10n()->t('You are now authenticated to pumpio.'); $o .= '
' . DI::l10n()->t('return to the connector page') . ''; } else { - Logger::notice('pumpio_connect: could not connect'); + DI::logger()->notice('pumpio_connect: could not connect'); $o = 'Could not connect to pumpio. Refresh the page or try again later.'; } @@ -345,7 +344,7 @@ function pumpio_hook_fork(array &$b) if (DI::pConfig()->get($post['uid'], 'pumpio', 'import')) { // Don't fork if it isn't a reply to a pump.io post if (($post['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::PUMPIO])) { - Logger::notice('No pump.io parent found for item ' . $post['id']); + DI::logger()->notice('No pump.io parent found for item ' . $post['id']); $b['execute'] = false; return; } @@ -389,7 +388,7 @@ function pumpio_send(array &$b) return; } - Logger::debug('pumpio_send: parameter ', $b); + DI::logger()->debug('pumpio_send: parameter ', $b); $b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], DI::contentItem()->addSharedPost($b)); @@ -399,7 +398,7 @@ function pumpio_send(array &$b) $orig_post = Post::selectFirst([], $condition); if (!DBA::isResult($orig_post)) { - Logger::notice('pumpio_send: no pumpio post ' . $b['parent']); + DI::logger()->notice('pumpio_send: no pumpio post ' . $b['parent']); return; } else { $iscomment = true; @@ -409,7 +408,7 @@ function pumpio_send(array &$b) $receiver = pumpio_getreceiver($b); - Logger::notice('pumpio_send: receiver ', $receiver); + DI::logger()->notice('pumpio_send: receiver ', $receiver); if (!count($receiver) && ($b['private'] == Item::PRIVATE) || !strstr($b['postopts'], 'pumpio')) { return; @@ -543,13 +542,13 @@ function pumpio_send(array &$b) } $post_id = $user->object->id; - Logger::notice('pumpio_send ' . $username . ': success ' . $post_id); + DI::logger()->notice('pumpio_send ' . $username . ': success ' . $post_id); if ($post_id && $iscomment) { - Logger::notice('pumpio_send ' . $username . ': Update extid ' . $post_id . ' for post id ' . $b['id']); + DI::logger()->notice('pumpio_send ' . $username . ': Update extid ' . $post_id . ' for post id ' . $b['id']); Item::update(['extid' => $post_id], ['id' => $b['id']]); } } else { - Logger::notice('pumpio_send '.$username.': '.$url.' general error: ' . print_r($user, true)); + DI::logger()->notice('pumpio_send '.$username.': '.$url.' general error: ' . print_r($user, true)); Worker::defer(); } } @@ -619,9 +618,9 @@ function pumpio_action(int $uid, string $uri, string $action, string $content = } if ($success) { - Logger::notice('pumpio_action '.$username.' '.$action.': success '.$uri); + DI::logger()->notice('pumpio_action '.$username.' '.$action.': success '.$uri); } else { - Logger::notice('pumpio_action '.$username.' '.$action.': general error: '.$uri); + DI::logger()->notice('pumpio_action '.$username.' '.$action.': general error: '.$uri); Worker::defer(); } } @@ -639,15 +638,15 @@ function pumpio_sync() if ($last) { $next = $last + ($poll_interval * 60); if ($next > time()) { - Logger::notice('pumpio: poll intervall not reached'); + DI::logger()->notice('pumpio: poll intervall not reached'); return; } } - Logger::notice('pumpio: cron_start'); + DI::logger()->notice('pumpio: cron_start'); $pconfigs = DBA::selectToArray('pconfig', ['uid'], ['cat' => 'pumpio', 'k' => 'mirror', 'v' => '1']); foreach ($pconfigs as $rr) { - Logger::notice('pumpio: mirroring user '.$rr['uid']); + DI::logger()->notice('pumpio: mirroring user '.$rr['uid']); pumpio_fetchtimeline($rr['uid']); } @@ -662,12 +661,12 @@ function pumpio_sync() foreach ($pconfigs as $rr) { if ($abandon_days != 0) { if (DBA::exists('user', ["uid = ? AND `login_date` >= ?", $rr['uid'], $abandon_limit])) { - Logger::notice('abandoned account: timeline from user '.$rr['uid'].' will not be imported'); + DI::logger()->notice('abandoned account: timeline from user '.$rr['uid'].' will not be imported'); continue; } } - Logger::notice('pumpio: importing timeline from user '.$rr['uid']); + DI::logger()->notice('pumpio: importing timeline from user '.$rr['uid']); pumpio_fetchinbox($rr['uid']); // check for new contacts once a day @@ -684,7 +683,7 @@ function pumpio_sync() } } - Logger::notice('pumpio: cron_end'); + DI::logger()->notice('pumpio: cron_end'); DI::keyValue()->set('pumpio_last_poll', time()); } @@ -729,7 +728,7 @@ function pumpio_fetchtimeline(int $uid) $url = 'https://'.$hostname.'/api/user/'.$username.'/feed/major'; - Logger::notice('pumpio: fetching for user ' . $uid . ' ' . $url . ' C:' . $client->client_id . ' CS:' . $client->client_secret . ' T:' . $client->access_token . ' TS:' . $client->access_token_secret); + DI::logger()->notice('pumpio: fetching for user ' . $uid . ' ' . $url . ' C:' . $client->client_id . ' CS:' . $client->client_secret . ' T:' . $client->access_token . ' TS:' . $client->access_token_secret); $useraddr = $username.'@'.$hostname; @@ -741,7 +740,7 @@ function pumpio_fetchtimeline(int $uid) } if (!$success) { - Logger::notice('pumpio: error fetching posts for user ' . $uid . ' ' . $useraddr . ' ', $user); + DI::logger()->notice('pumpio: error fetching posts for user ' . $uid . ' ' . $useraddr . ' ', $user); return; } @@ -801,11 +800,11 @@ function pumpio_fetchtimeline(int $uid) } } - Logger::notice('pumpio: posting for user ' . $uid); + DI::logger()->notice('pumpio: posting for user ' . $uid); Item::insert($postarray, true); - Logger::notice('pumpio: posting done - user ' . $uid); + DI::logger()->notice('pumpio: posting done - user ' . $uid); } } } @@ -846,16 +845,16 @@ function pumpio_dounlike(int $uid, array $self, $post, string $own_id) Item::markForDeletion(['verb' => Activity::LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']]); if (DBA::isResult($contact)) { - Logger::notice('pumpio_dounlike: unliked existing like. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']); + DI::logger()->notice('pumpio_dounlike: unliked existing like. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']); } else { - Logger::notice('pumpio_dounlike: not found. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' Url ' . $orig_post['uri']); + DI::logger()->notice('pumpio_dounlike: not found. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' Url ' . $orig_post['uri']); } } function pumpio_dolike(int $uid, array $self, $post, string $own_id, $threadcompletion = true) { if (empty($post->object->id)) { - Logger::info('Got empty like: '.print_r($post, true)); + DI::logger()->info('Got empty like: '.print_r($post, true)); return; } @@ -900,7 +899,7 @@ function pumpio_dolike(int $uid, array $self, $post, string $own_id, $threadcomp ]; if (Post::exists($condition)) { - Logger::notice('pumpio_dolike: found existing like. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']); + DI::logger()->notice('pumpio_dolike: found existing like. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']); return; } @@ -934,7 +933,7 @@ function pumpio_dolike(int $uid, array $self, $post, string $own_id, $threadcomp $ret = Item::insert($likedata); - Logger::notice('pumpio_dolike: ' . $ret . ' User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']); + DI::logger()->notice('pumpio_dolike: ' . $ret . ' User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']); } function pumpio_get_contact($uid, $contact, $no_insert = false) @@ -1405,7 +1404,7 @@ function pumpio_fetchallcomments($uid, $id) $hostname = DI::pConfig()->get($uid, 'pumpio', 'host'); $username = DI::pConfig()->get($uid, 'pumpio', 'user'); - Logger::notice('pumpio_fetchallcomments: completing comment for user ' . $uid . ' post id ' . $id); + DI::logger()->notice('pumpio_fetchallcomments: completing comment for user ' . $uid . ' post id ' . $id); $own_id = 'https://' . $hostname . '/' . $username; @@ -1430,7 +1429,7 @@ function pumpio_fetchallcomments($uid, $id) $client->access_token = $otoken; $client->access_token_secret = $osecret; - Logger::notice('pumpio_fetchallcomments: fetching comment for user ' . $uid . ', URL ' . $url); + DI::logger()->notice('pumpio_fetchallcomments: fetching comment for user ' . $uid . ', URL ' . $url); $item = new \stdClass(); @@ -1495,7 +1494,7 @@ function pumpio_fetchallcomments($uid, $id) $post->object = $item; - Logger::notice('pumpio_fetchallcomments: posting comment ' . $post->object->id . ' ', json_decode(json_encode($post), true)); + DI::logger()->notice('pumpio_fetchallcomments: posting comment ' . $post->object->id . ' ', json_decode(json_encode($post), true)); pumpio_dopost($client, $uid, $self, $post, $own_id, false); } } diff --git a/pumpio/pumpio_sync.php b/pumpio/pumpio_sync.php index beaf6e81..09548c6d 100644 --- a/pumpio/pumpio_sync.php +++ b/pumpio/pumpio_sync.php @@ -1,5 +1,5 @@ DI::config()->get('system', 'maxloadavg', 50)) { - Logger::notice('system: load ' . $load[0] . ' too high. Pumpio sync deferred to next scheduled run.'); + DI::logger()->notice('system: load ' . $load[0] . ' too high. Pumpio sync deferred to next scheduled run.'); return; } } diff --git a/randplace/randplace.php b/randplace/randplace.php index 5cb07597..89a75f98 100644 --- a/randplace/randplace.php +++ b/randplace/randplace.php @@ -20,7 +20,6 @@ */ use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; @@ -40,7 +39,7 @@ function randplace_install() Hook::register('addon_settings', 'addon/randplace/randplace.php', 'randplace_settings'); Hook::register('addon_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post'); - Logger::notice("installed randplace"); + DI::logger()->notice("installed randplace"); } function randplace_uninstall() @@ -50,7 +49,7 @@ function randplace_uninstall() * * Except hooks, they are all unregistered automatically and don't need to be unregistered manually. */ - Logger::notice("removed randplace"); + DI::logger()->notice("removed randplace"); } function randplace_post_hook(&$item) @@ -61,7 +60,7 @@ function randplace_post_hook(&$item) * - A status post by a profile owner * - The profile owner must have allowed our addon */ - Logger::notice('randplace invoked'); + DI::logger()->notice('randplace invoked'); if (!DI::userSession()->getLocalUserId()) { /* non-zero if this is a logged in user of this system */ diff --git a/ratioed/RatioedPanel.php b/ratioed/RatioedPanel.php index 91665640..4cf5d7ff 100644 --- a/ratioed/RatioedPanel.php +++ b/ratioed/RatioedPanel.php @@ -3,7 +3,6 @@ namespace Friendica\Addon\ratioed; use Friendica\Content\Pager; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\DI; @@ -260,7 +259,7 @@ FROM ( protected function setupUserCallback(): \Closure { - Logger::debug("ratioed: setupUserCallback"); + DI::logger()->debug("ratioed: setupUserCallback"); $parentCallback = parent::setupUserCallback(); return function ($user) use ($parentCallback) { $blocked_count = DBA::count('user-contact', ['uid' => $user['uid'], 'is-blocked' => 1]); @@ -310,7 +309,7 @@ FROM ( $this->fillReplyGuyData($user); $user = $parentCallback($user); - Logger::debug("ratioed: setupUserCallback", [ + DI::logger()->debug("ratioed: setupUserCallback", [ 'uid' => $user['uid'], 'blocked_by' => $user['blocked_by'], 'comments' => $user['comments'], diff --git a/ratioed/ratioed.php b/ratioed/ratioed.php index 443fdaa9..5cc6d539 100644 --- a/ratioed/ratioed.php +++ b/ratioed/ratioed.php @@ -8,7 +8,6 @@ use Friendica\Addon\ratioed\RatioedPanel; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\DI; /** @@ -18,7 +17,7 @@ function ratioed_install() { Hook::register('moderation_users_tabs', 'addon/ratioed/ratioed.php', 'ratioed_users_tabs'); - Logger::info("ratioed: installed"); + DI::logger()->info("ratioed: installed"); } /** @@ -34,7 +33,7 @@ function ratioed_module() {} * @param array $arr Parameters, including "tabs" which is the list to modify, and "selectedTab", which is the currently selected tab ID */ function ratioed_users_tabs(array &$arr) { - Logger::debug("ratioed: users tabs"); + DI::logger()->debug("ratioed: users tabs"); array_push($arr['tabs'], [ 'label' => DI::l10n()->t('Behaviour'), @@ -50,7 +49,7 @@ function ratioed_users_tabs(array &$arr) { * @brief Displays the ratioed tab in the moderation panel */ function ratioed_content() { - Logger::debug("ratioed: content"); + DI::logger()->debug("ratioed: content"); $ratioed = DI::getDice()->create(RatioedPanel::class, [$_SERVER]); $httpException = DI::getDice()->create(Friendica\Module\Special\HTTPException::class); diff --git a/saml/saml.php b/saml/saml.php index 81a6bfcc..c8824b46 100755 --- a/saml/saml.php +++ b/saml/saml.php @@ -8,7 +8,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\DI; @@ -63,7 +62,7 @@ function saml_metadata() ); } } catch (Exception $e) { - Logger::error($e->getMessage()); + DI::logger()->error($e->getMessage()); } } @@ -125,7 +124,7 @@ function saml_is_configured() function saml_sso_initiate(string &$body) { if (!saml_is_configured()) { - Logger::warning('SAML SSO tried to trigger, but the SAML addon is not configured yet!'); + DI::logger()->warning('SAML SSO tried to trigger, but the SAML addon is not configured yet!'); return; } @@ -154,7 +153,7 @@ function saml_sso_reply() if (!empty($errors)) { echo 'Errors encountered.'; - Logger::error(implode(', ', $errors)); + DI::logger()->error(implode(', ', $errors)); exit(); } @@ -190,7 +189,7 @@ function saml_sso_reply() function saml_slo_initiate() { if (!saml_is_configured()) { - Logger::warning('SAML SLO tried to trigger, but the SAML addon is not configured yet!'); + DI::logger()->warning('SAML SLO tried to trigger, but the SAML addon is not configured yet!'); return; } @@ -221,7 +220,7 @@ function saml_slo_reply() if (empty($errors)) { $auth->redirectTo(DI::baseUrl()); } else { - Logger::error(implode(', ', $errors)); + DI::logger()->error(implode(', ', $errors)); } } @@ -314,7 +313,7 @@ function saml_addon_admin_post() function saml_create_user($username, $email, $name) { if (!strlen($email) || !strlen($name)) { - Logger::error('Could not create user: no email or username given.'); + DI::logger()->error('Could not create user: no email or username given.'); return false; } @@ -336,7 +335,7 @@ function saml_create_user($username, $email, $name) return $user; } catch (Exception $e) { - Logger::error( + DI::logger()->error( 'Exception while creating user', [ 'username' => $username, diff --git a/securemail/securemail.php b/securemail/securemail.php index b56c0cbc..7b412395 100644 --- a/securemail/securemail.php +++ b/securemail/securemail.php @@ -8,7 +8,6 @@ use Friendica\Addon\securemail\SecureTestEmail; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Object\EMail\IEmail; @@ -22,7 +21,7 @@ function securemail_install() Hook::register('emailer_send_prepare', 'addon/securemail/securemail.php', 'securemail_emailer_send_prepare', 10); - Logger::notice('installed securemail'); + DI::logger()->notice('installed securemail'); } /** diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index bd115115..8663aaea 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -40,7 +40,6 @@ require_once __DIR__ . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . ' use CodebirdSN\CodebirdSN; use Friendica\Content\Text\Plaintext; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Database\DBA; @@ -58,7 +57,7 @@ function statusnet_install() Hook::register('hook_fork', 'addon/statusnet/statusnet.php', 'statusnet_hook_fork'); Hook::register('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local'); Hook::register('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets'); - Logger::notice('installed GNU Social'); + DI::logger()->notice('installed GNU Social'); } function statusnet_jot_nets(array &$jotnets_fields) @@ -355,7 +354,7 @@ function statusnet_post_hook(array &$b) return; } - Logger::notice('GNU Socialpost invoked'); + DI::logger()->notice('GNU Socialpost invoked'); DI::pConfig()->load($b['uid'], 'statusnet'); @@ -407,7 +406,7 @@ function statusnet_post_hook(array &$b) $cb->setToken($otoken, $osecret); $result = $cb->statuses_update($postdata); //$result = $dent->post('statuses/update', $postdata); - Logger::info('statusnet_post send, result: ' . print_r($result, true) . + DI::logger()->info('statusnet_post send, result: ' . print_r($result, true) . "\nmessage: " . $msg . "\nOriginal post: " . print_r($b, true) . "\nPost Data: " . print_r($postdata, true)); if (!empty($result->source)) { @@ -415,9 +414,9 @@ function statusnet_post_hook(array &$b) } if (!empty($result->error)) { - Logger::notice('Send to GNU Social failed: "' . $result->error . '"'); + DI::logger()->notice('Send to GNU Social failed: "' . $result->error . '"'); } elseif ($iscomment) { - Logger::notice('statusnet_post: Update extid ' . $result->id . ' for post id ' . $b['id']); + DI::logger()->notice('statusnet_post: Update extid ' . $result->id . ' for post id ' . $b['id']); Item::update(['extid' => $hostname . '::' . $result->id, 'body' => $result->text], ['id' => $b['id']]); } } diff --git a/tesseract/tesseract.php b/tesseract/tesseract.php index 4c630dbb..a07c690c 100644 --- a/tesseract/tesseract.php +++ b/tesseract/tesseract.php @@ -7,8 +7,8 @@ */ use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\System; +use Friendica\DI; use thiagoalessio\TesseractOCR\TesseractOCR; require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; @@ -17,7 +17,7 @@ function tesseract_install() { Hook::register('ocr-detection', __FILE__, 'tesseract_ocr_detection'); - Logger::notice('installed tesseract'); + DI::logger()->notice('installed tesseract'); } function tesseract_ocr_detection(&$media) @@ -33,6 +33,6 @@ function tesseract_ocr_detection(&$media) $ocr->imageData($media['img_str'], strlen($media['img_str'])); $media['description'] = $ocr->run(); } catch (\Throwable $th) { - Logger::info('Error calling TesseractOCR', ['message' => $th->getMessage()]); + DI::logger()->info('Error calling TesseractOCR', ['message' => $th->getMessage()]); } } diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php index 12f13aa8..819c0ca5 100644 --- a/tumblr/tumblr.php +++ b/tumblr/tumblr.php @@ -14,7 +14,6 @@ use Friendica\Content\Text\NPF; use Friendica\Core\Cache\Enum\Duration; use Friendica\Core\Config\Util\ConfigFileManager; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Core\System; @@ -60,7 +59,7 @@ function tumblr_install() Hook::register('check_item_notification', __FILE__, 'tumblr_check_item_notification'); Hook::register('probe_detect', __FILE__, 'tumblr_probe_detect'); Hook::register('item_by_link', __FILE__, 'tumblr_item_by_link'); - Logger::info('installed tumblr'); + DI::logger()->info('installed tumblr'); } function tumblr_load_config(ConfigFileManager $loader) @@ -121,16 +120,16 @@ function tumblr_item_by_link(array &$hookData) return; } - Logger::debug('Found tumblr post', ['url' => $hookData['uri'], 'blog' => $matches[1], 'id' => $matches[2]]); + DI::logger()->debug('Found tumblr post', ['url' => $hookData['uri'], 'blog' => $matches[1], 'id' => $matches[2]]); $parameters = ['id' => $matches[2], 'reblog_info' => false, 'notes_info' => false, 'npf' => false]; $result = tumblr_get($hookData['uid'], 'blog/' . $matches[1] . '/posts', $parameters); if ($result->meta->status > 399) { - Logger::notice('Error fetching status', ['meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'blog' => $matches[1], 'id' => $matches[2]]); + DI::logger()->notice('Error fetching status', ['meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'blog' => $matches[1], 'id' => $matches[2]]); return []; } - Logger::debug('Got post', ['blog' => $matches[1], 'id' => $matches[2], 'result' => $result->response->posts]); + DI::logger()->debug('Got post', ['blog' => $matches[1], 'id' => $matches[2], 'result' => $result->response->posts]); if (!empty($result->response->posts)) { $hookData['item_id'] = tumblr_process_post($result->response->posts[0], $hookData['uid'], Item::PR_FETCHED); Item::incrementInbound(Protocol::TUMBLR); @@ -159,20 +158,20 @@ function tumblr_follow(array &$hook_data) return; } - Logger::debug('Check if contact is Tumblr', ['url' => $hook_data['url']]); + DI::logger()->debug('Check if contact is Tumblr', ['url' => $hook_data['url']]); $fields = tumblr_get_contact_by_url($hook_data['url'], $uid); if (empty($fields)) { - Logger::debug('Contact is not a Tumblr contact', ['url' => $hook_data['url']]); + DI::logger()->debug('Contact is not a Tumblr contact', ['url' => $hook_data['url']]); return; } $result = tumblr_post($uid, 'user/follow', ['url' => $fields['url']]); if ($result->meta->status <= 399) { $hook_data['contact'] = $fields; - Logger::debug('Successfully start following', ['url' => $fields['url']]); + DI::logger()->debug('Successfully start following', ['url' => $fields['url']]); } else { - Logger::notice('Following failed', ['meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'url' => $fields['url']]); + DI::logger()->notice('Following failed', ['meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'url' => $fields['url']]); } } @@ -415,11 +414,11 @@ function tumblr_cron() if ($last) { $next = $last + ($poll_interval * 60); if ($next > time()) { - Logger::notice('poll interval not reached'); + DI::logger()->notice('poll interval not reached'); return; } } - Logger::notice('cron_start'); + DI::logger()->notice('cron_start'); $abandon_days = intval(DI::config()->get('system', 'account_abandon_days')); if ($abandon_days < 1) { @@ -432,30 +431,30 @@ function tumblr_cron() foreach ($pconfigs as $pconfig) { if ($abandon_days != 0) { if (!DBA::exists('user', ["`uid` = ? AND `login_date` >= ?", $pconfig['uid'], $abandon_limit])) { - Logger::notice('abandoned account: timeline from user will not be imported', ['user' => $pconfig['uid']]); + DI::logger()->notice('abandoned account: timeline from user will not be imported', ['user' => $pconfig['uid']]); continue; } } - Logger::notice('importing timeline - start', ['user' => $pconfig['uid']]); + DI::logger()->notice('importing timeline - start', ['user' => $pconfig['uid']]); tumblr_fetch_dashboard($pconfig['uid'], $last); tumblr_fetch_tags($pconfig['uid'], $last); - Logger::notice('importing timeline - done', ['user' => $pconfig['uid']]); + DI::logger()->notice('importing timeline - done', ['user' => $pconfig['uid']]); } $last_clean = DI::keyValue()->get('tumblr_last_clean'); if (empty($last_clean) || ($last_clean + 86400 < time())) { - Logger::notice('Start contact cleanup'); + DI::logger()->notice('Start contact cleanup'); $contacts = DBA::select('account-user-view', ['id', 'pid'], ["`network` = ? AND `uid` != ? AND `rel` = ?", Protocol::TUMBLR, 0, Contact::NOTHING]); while ($contact = DBA::fetch($contacts)) { Worker::add(Worker::PRIORITY_LOW, 'MergeContact', $contact['pid'], $contact['id'], 0); } DBA::close($contacts); DI::keyValue()->set('tumblr_last_clean', time()); - Logger::notice('Contact cleanup done'); + DI::logger()->notice('Contact cleanup done'); } - Logger::notice('cron_end'); + DI::logger()->notice('cron_end'); DI::keyValue()->set('tumblr_last_poll', time()); } @@ -478,7 +477,7 @@ function tumblr_hook_fork(array &$b) if (DI::pConfig()->get($post['uid'], 'tumblr', 'import')) { // Don't post if it isn't a reply to a tumblr post if (($post['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::TUMBLR])) { - Logger::notice('No tumblr parent found', ['item' => $post['id']]); + DI::logger()->notice('No tumblr parent found', ['item' => $post['id']]); $b['execute'] = false; return; } @@ -525,20 +524,20 @@ function tumblr_send(array &$b) } if ($b['gravity'] != Item::GRAVITY_PARENT) { - Logger::debug('Got comment', ['item' => $b]); + DI::logger()->debug('Got comment', ['item' => $b]); $parent = tumblr_get_post_from_uri($b['thr-parent']); if (empty($parent)) { - Logger::notice('No tumblr post', ['thr-parent' => $b['thr-parent']]); + DI::logger()->notice('No tumblr post', ['thr-parent' => $b['thr-parent']]); return; } - Logger::debug('Parent found', ['parent' => $parent]); + DI::logger()->debug('Parent found', ['parent' => $parent]); $page = tumblr_get_page($b['uid']); if ($b['gravity'] == Item::GRAVITY_COMMENT) { - Logger::notice('Commenting is not supported (yet)'); + DI::logger()->notice('Commenting is not supported (yet)'); } else { if (($b['verb'] == Activity::LIKE) && !$b['deleted']) { $params = ['id' => $parent['id'], 'reblog_key' => $parent['reblog_key']]; @@ -562,12 +561,12 @@ function tumblr_send(array &$b) } if ($result->meta->status < 400) { - Logger::info('Successfully performed activity', ['verb' => $b['verb'], 'deleted' => $b['deleted'], 'meta' => $result->meta, 'response' => $result->response]); + DI::logger()->info('Successfully performed activity', ['verb' => $b['verb'], 'deleted' => $b['deleted'], 'meta' => $result->meta, 'response' => $result->response]); if (!$b['deleted'] && !empty($result->response->id_string)) { Item::update(['extid' => 'tumblr::' . $result->response->id_string], ['guid' => $b['guid']]); } } else { - Logger::notice('Error while performing activity', ['verb' => $b['verb'], 'deleted' => $b['deleted'], 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]); + DI::logger()->notice('Error while performing activity', ['verb' => $b['verb'], 'deleted' => $b['deleted'], 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]); } } return; @@ -665,9 +664,9 @@ function tumblr_send_legacy(array $b) $result = tumblr_post($b['uid'], 'blog/' . $page . '/post', $params); if ($result->meta->status < 400) { - Logger::info('Success (legacy)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response]); + DI::logger()->info('Success (legacy)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response]); } else { - Logger::notice('Error posting blog (legacy)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]); + DI::logger()->notice('Error posting blog (legacy)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]); } } @@ -676,7 +675,7 @@ function tumblr_send_npf(array $post): bool $page = tumblr_get_page($post['uid']); if (empty($page)) { - Logger::notice('Missing page, post will not be send to Tumblr.', ['uid' => $post['uid'], 'page' => $page, 'id' => $post['id']]); + DI::logger()->notice('Missing page, post will not be send to Tumblr.', ['uid' => $post['uid'], 'page' => $page, 'id' => $post['id']]); // "true" is returned, since the legacy function will fail as well. return true; } @@ -707,10 +706,10 @@ function tumblr_send_npf(array $post): bool $result = tumblr_post($post['uid'], 'blog/' . $page . '/posts', $params); if ($result->meta->status < 400) { - Logger::info('Success (NPF)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response]); + DI::logger()->info('Success (NPF)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response]); return true; } else { - Logger::notice('Error posting blog (NPF)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]); + DI::logger()->notice('Error posting blog (NPF)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]); return false; } } @@ -747,10 +746,10 @@ function tumblr_fetch_tags(int $uid, int $last_poll) foreach (array_reverse($data->response) as $post) { $id = tumblr_process_post($post, $uid, Item::PR_TAG, $last_poll); if (!empty($id)) { - Logger::debug('Tag post imported', ['tag' => $tag, 'id' => $id]); + DI::logger()->debug('Tag post imported', ['tag' => $tag, 'id' => $id]); $post = Post::selectFirst(['uri-id'], ['id' => $id]); $stored = Post\Category::storeFileByURIId($post['uri-id'], $uid, Post\Category::SUBCRIPTION, $tag); - Logger::debug('Stored tag subscription for user', ['uri-id' => $post['uri-id'], 'uid' => $uid, 'tag' => $tag, 'stored' => $stored]); + DI::logger()->debug('Stored tag subscription for user', ['uri-id' => $post['uri-id'], 'uid' => $uid, 'tag' => $tag, 'stored' => $stored]); Item::incrementInbound(Protocol::TUMBLR); } } @@ -775,7 +774,7 @@ function tumblr_fetch_dashboard(int $uid, int $last_poll) $dashboard = tumblr_get($uid, 'user/dashboard', $parameters); if ($dashboard->meta->status > 399) { - Logger::notice('Error fetching dashboard', ['meta' => $dashboard->meta, 'response' => $dashboard->response, 'errors' => $dashboard->errors]); + DI::logger()->notice('Error fetching dashboard', ['meta' => $dashboard->meta, 'response' => $dashboard->response, 'errors' => $dashboard->errors]); return []; } @@ -788,7 +787,7 @@ function tumblr_fetch_dashboard(int $uid, int $last_poll) $last = $post->id; } - Logger::debug('Importing post', ['uid' => $uid, 'created' => date(DateTimeFormat::MYSQL, $post->timestamp), 'id' => $post->id_string]); + DI::logger()->debug('Importing post', ['uid' => $uid, 'created' => date(DateTimeFormat::MYSQL, $post->timestamp), 'id' => $post->id_string]); tumblr_process_post($post, $uid, Item::PR_NONE, $last_poll); Item::incrementInbound(Protocol::TUMBLR); @@ -1063,7 +1062,7 @@ function tumblr_get_type_replacement(array $data, string $plink): string } default: - Logger::notice('Unknown type', ['type' => $data['type'], 'data' => $data, 'plink' => $plink]); + DI::logger()->notice('Unknown type', ['type' => $data['type'], 'data' => $data, 'plink' => $plink]); $body = ''; } @@ -1118,9 +1117,9 @@ function tumblr_get_contact(stdClass $blog, int $uid): array $cid = $contact['id']; Contact::update($fields, ['id' => $cid], true); } - Logger::debug('Get user contact', ['id' => $cid, 'uid' => $uid, 'update' => $update]); + DI::logger()->debug('Get user contact', ['id' => $cid, 'uid' => $uid, 'update' => $update]); } else { - Logger::debug('Get public contact', ['id' => $cid, 'uid' => $uid, 'update' => $update]); + DI::logger()->debug('Get public contact', ['id' => $cid, 'uid' => $uid, 'update' => $update]); } if (!empty($avatar)) { @@ -1156,13 +1155,13 @@ function tumblr_get_contact_fields(stdClass $blog, int $uid, bool $update): arra ]; if (!$update) { - Logger::debug('Got contact fields', ['uid' => $uid, 'url' => $fields['url']]); + DI::logger()->debug('Got contact fields', ['uid' => $uid, 'url' => $fields['url']]); return $fields; } $info = tumblr_get($uid, 'blog/' . $blog->uuid . '/info'); if ($info->meta->status > 399) { - Logger::notice('Error fetching blog info', ['meta' => $info->meta, 'response' => $info->response, 'errors' => $info->errors]); + DI::logger()->notice('Error fetching blog info', ['meta' => $info->meta, 'response' => $info->response, 'errors' => $info->errors]); return $fields; } Item::incrementInbound(Protocol::TUMBLR); @@ -1184,7 +1183,7 @@ function tumblr_get_contact_fields(stdClass $blog, int $uid, bool $update): arra $fields['header'] = $info->response->blog->theme->header_image_focused; - Logger::debug('Got updated contact fields', ['uid' => $uid, 'url' => $fields['url']]); + DI::logger()->debug('Got updated contact fields', ['uid' => $uid, 'url' => $fields['url']]); return $fields; } @@ -1226,7 +1225,7 @@ function tumblr_get_blogs(int $uid): array { $userinfo = tumblr_get($uid, 'user/info'); if ($userinfo->meta->status > 399) { - Logger::notice('Error fetching blogs', ['meta' => $userinfo->meta, 'response' => $userinfo->response, 'errors' => $userinfo->errors]); + DI::logger()->notice('Error fetching blogs', ['meta' => $userinfo->meta, 'response' => $userinfo->response, 'errors' => $userinfo->errors]); return []; } @@ -1282,15 +1281,15 @@ function tumblr_get_contact_by_url(string $url, int $uid): ?array return null; } - Logger::debug('Update Tumblr blog data', ['url' => $url, 'blog' => $blog, 'uid' => $uid]); + DI::logger()->debug('Update Tumblr blog data', ['url' => $url, 'blog' => $blog, 'uid' => $uid]); $info = tumblr_get($uid, 'blog/' . $blog . '/info'); if ($info->meta->status > 399) { - Logger::notice('Error fetching blog info', ['meta' => $info->meta, 'response' => $info->response, 'errors' => $info->errors, 'blog' => $blog, 'uid' => $uid]); + DI::logger()->notice('Error fetching blog info', ['meta' => $info->meta, 'response' => $info->response, 'errors' => $info->errors, 'blog' => $blog, 'uid' => $uid]); return null; } - Logger::debug('Got data', ['blog' => $blog, 'meta' => $info->meta]); + DI::logger()->debug('Got data', ['blog' => $blog, 'meta' => $info->meta]); Item::incrementInbound(Protocol::TUMBLR); $baseurl = 'https://tumblr.com'; @@ -1419,7 +1418,7 @@ function tumblr_get_token(int $uid, string $code = ''): string $refresh_token = DI::pConfig()->get($uid, 'tumblr', 'refresh_token'); if (empty($code) && !empty($access_token) && ($expires_at > (time()))) { - Logger::debug('Got token', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]); + DI::logger()->debug('Got token', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]); return $access_token; } @@ -1431,11 +1430,11 @@ function tumblr_get_token(int $uid, string $code = ''): string if (empty($refresh_token) && empty($code)) { $result = tumblr_exchange_token($uid); if (empty($result->refresh_token)) { - Logger::info('Invalid result while exchanging token', ['uid' => $uid]); + DI::logger()->info('Invalid result while exchanging token', ['uid' => $uid]); return ''; } $expires_at = time() + $result->expires_in; - Logger::debug('Updated token from OAuth1 to OAuth2', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]); + DI::logger()->debug('Updated token from OAuth1 to OAuth2', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]); } else { if (!empty($code)) { $parameters['code'] = $code; @@ -1447,18 +1446,18 @@ function tumblr_get_token(int $uid, string $code = ''): string $curlResult = DI::httpClient()->post('https://api.tumblr.com/v2/oauth2/token', $parameters); if (!$curlResult->isSuccess()) { - Logger::info('Error fetching token', ['uid' => $uid, 'code' => $code, 'result' => $curlResult->getBodyString(), 'parameters' => $parameters]); + DI::logger()->info('Error fetching token', ['uid' => $uid, 'code' => $code, 'result' => $curlResult->getBodyString(), 'parameters' => $parameters]); return ''; } $result = json_decode($curlResult->getBodyString()); if (empty($result)) { - Logger::info('Invalid result when updating token', ['uid' => $uid]); + DI::logger()->info('Invalid result when updating token', ['uid' => $uid]); return ''; } $expires_at = time() + $result->expires_in; - Logger::debug('Renewed token', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]); + DI::logger()->debug('Renewed token', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]); } DI::pConfig()->set($uid, 'tumblr', 'access_token', $result->access_token); @@ -1502,7 +1501,7 @@ function tumblr_exchange_token(int $uid): stdClass $response = $client->post('oauth2/exchange', ['auth' => 'oauth']); return json_decode($response->getBody()->getContents()); } catch (RequestException $exception) { - Logger::notice('Exchange failed', ['code' => $exception->getCode(), 'message' => $exception->getMessage()]); + DI::logger()->notice('Exchange failed', ['code' => $exception->getCode(), 'message' => $exception->getMessage()]); return new stdClass; } } diff --git a/twitter/twitter.php b/twitter/twitter.php index ea4ae356..a9654405 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -38,7 +38,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Content\Text\Plaintext; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Core\Worker; use Friendica\DI; @@ -217,7 +216,7 @@ function twitter_post_hook(array &$b) $b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], DI::contentItem()->addSharedPost($b)); - Logger::notice('twitter post invoked', ['id' => $b['id'], 'guid' => $b['guid']]); + DI::logger()->notice('twitter post invoked', ['id' => $b['id'], 'guid' => $b['guid']]); DI::pConfig()->load($b['uid'], 'twitter'); @@ -227,17 +226,17 @@ function twitter_post_hook(array &$b) $access_secret = DI::pConfig()->get($b['uid'], 'twitter', 'access_secret'); if (empty($api_key) || empty($api_secret) || empty($access_token) || empty($access_secret)) { - Logger::info('Missing keys, secrets or tokens.'); + DI::logger()->info('Missing keys, secrets or tokens.'); return; } $msgarr = Plaintext::getPost($b, 280, true, BBCode::TWITTER); - Logger::debug('Got plaintext', ['id' => $b['id'], 'message' => $msgarr]); + DI::logger()->debug('Got plaintext', ['id' => $b['id'], 'message' => $msgarr]); $media_ids = []; if (!empty($msgarr['images']) || !empty($msgarr['remote_images'])) { - Logger::info('Got images', ['id' => $b['id'], 'images' => $msgarr['images'] ?? []]); + DI::logger()->info('Got images', ['id' => $b['id'], 'images' => $msgarr['images'] ?? []]); $retrial = Worker::getRetrial(); if ($retrial > 4) { @@ -250,7 +249,7 @@ function twitter_post_hook(array &$b) try { $media_ids[] = twitter_upload_image($b['uid'], $image, $retrial); } catch (RequestException $exception) { - Logger::warning('Error while uploading image', ['image' => $image, 'code' => $exception->getCode(), 'message' => $exception->getMessage()]); + DI::logger()->warning('Error while uploading image', ['image' => $image, 'code' => $exception->getCode(), 'message' => $exception->getMessage()]); Worker::defer(); return; } @@ -259,13 +258,13 @@ function twitter_post_hook(array &$b) $in_reply_to_tweet_id = 0; - Logger::debug('Post message', ['id' => $b['id'], 'parts' => count($msgarr['parts'])]); + DI::logger()->debug('Post message', ['id' => $b['id'], 'parts' => count($msgarr['parts'])]); foreach ($msgarr['parts'] as $key => $part) { try { $id = twitter_post_status($b['uid'], $part, $media_ids, $in_reply_to_tweet_id); - Logger::info('twitter_post send', ['part' => $key, 'id' => $b['id'], 'result' => $id]); + DI::logger()->info('twitter_post send', ['part' => $key, 'id' => $b['id'], 'result' => $id]); } catch (RequestException $exception) { - Logger::warning('Error while posting message', ['part' => $key, 'id' => $b['id'], 'code' => $exception->getCode(), 'message' => $exception->getMessage()]); + DI::logger()->warning('Error while posting message', ['part' => $key, 'id' => $b['id'], 'code' => $exception->getCode(), 'message' => $exception->getMessage()]); $status = [ 'code' => $exception->getCode(), 'reason' => $exception->getResponse()->getReasonPhrase(), @@ -319,9 +318,9 @@ function twitter_upload_image(int $uid, array $image, int $retrial) $picturedata = $picture->asString(); $new_size = strlen($picturedata); - Logger::info('Uploading', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size, 'image' => $image]); + DI::logger()->info('Uploading', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size, 'image' => $image]); $media = twitter_post($uid, 'https://upload.twitter.com/1.1/media/upload.json', 'form_params', ['media' => base64_encode($picturedata)]); - Logger::info('Uploading done', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size, 'image' => $image]); + DI::logger()->info('Uploading done', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size, 'image' => $image]); if (isset($media->media_id_string)) { $media_id = $media->media_id_string; @@ -334,10 +333,10 @@ function twitter_upload_image(int $uid, array $image, int $retrial) ] ]; $ret = twitter_post($uid, 'https://upload.twitter.com/1.1/media/metadata/create.json', 'json', $data); - Logger::info('Metadata create', ['uid' => $uid, 'data' => $data, 'return' => $ret]); + DI::logger()->info('Metadata create', ['uid' => $uid, 'data' => $data, 'return' => $ret]); } } else { - Logger::error('Failed upload', ['uid' => $uid, 'size' => strlen($picturedata), 'image' => $image['url'], 'return' => $media]); + DI::logger()->error('Failed upload', ['uid' => $uid, 'size' => strlen($picturedata), 'image' => $image['url'], 'return' => $media]); throw new Exception('Failed upload of ' . $image['url']); } @@ -373,7 +372,7 @@ function twitter_post(int $uid, string $url, string $type, array $data): stdClas DI::pConfig()->set($uid, 'twitter', 'last_status', $status); $content = json_decode($body) ?? new stdClass; - Logger::debug('Success', ['content' => $content]); + DI::logger()->debug('Success', ['content' => $content]); return $content; } @@ -402,7 +401,7 @@ function twitter_test_connection(int $uid) 'content' => $response->getBody()->getContents() ]; DI::pConfig()->set(1, 'twitter', 'last_status', $status); - Logger::info('Test successful', ['uid' => $uid]); + DI::logger()->info('Test successful', ['uid' => $uid]); } catch (RequestException $exception) { $status = [ 'code' => $exception->getCode(), @@ -410,6 +409,6 @@ function twitter_test_connection(int $uid) 'content' => $exception->getMessage() ]; DI::pConfig()->set(1, 'twitter', 'last_status', $status); - Logger::info('Test failed', ['uid' => $uid]); + DI::logger()->info('Test failed', ['uid' => $uid]); } } diff --git a/wppost/wppost.php b/wppost/wppost.php index f2ee5d21..de216806 100644 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -9,7 +9,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Content\Text\HTML; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\DI; @@ -257,13 +256,13 @@ function wppost_send(array &$b) EOT; - Logger::debug('wppost: data: ' . $xml); + DI::logger()->debug('wppost: data: ' . $xml); $x = ''; if ($wp_blog !== 'test') { $x = DI::httpClient()->post($wp_blog, $xml)->getBodyString(); } - Logger::info('posted to wordpress: ' . $x); + DI::logger()->info('posted to wordpress: ' . $x); } }