From f6faae5bb10299c81ab4ca2e94463246e47cacf7 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 20 Oct 2021 18:53:52 +0000 Subject: [PATCH] Replace deprecated `log` calls --- mod/display.php | 2 +- mod/pubsub.php | 26 +++++------ mod/pubsubhubbub.php | 18 ++++---- mod/redir.php | 6 +-- mod/wall_upload.php | 12 +++--- src/BaseModule.php | 8 ++-- src/Model/Contact.php | 10 ++--- src/Model/Event.php | 2 +- src/Model/Item.php | 8 ++-- src/Model/Mail.php | 4 +- src/Model/User.php | 2 +- src/Module/Attach.php | 2 +- src/Module/Register.php | 2 +- src/Protocol/DFRN.php | 84 ++++++++++++++++++------------------ src/Protocol/OStatus.php | 70 +++++++++++++++--------------- src/Protocol/Salmon.php | 12 +++--- src/Util/Crypto.php | 8 ++-- src/Util/DateTimeFormat.php | 2 +- src/Util/HTTPSignature.php | 12 +++--- src/Util/Network.php | 2 +- src/Util/Strings.php | 2 +- src/Util/XML.php | 8 ++-- src/Worker/CheckVersion.php | 8 ++-- src/Worker/Directory.php | 2 +- src/Worker/ProfileUpdate.php | 2 +- src/Worker/PubSubPublish.php | 8 ++-- view/theme/frio/theme.php | 2 +- view/theme/vier/style.php | 2 +- 28 files changed, 163 insertions(+), 163 deletions(-) diff --git a/mod/display.php b/mod/display.php index ef835848ea..b53dd35438 100644 --- a/mod/display.php +++ b/mod/display.php @@ -99,7 +99,7 @@ function display_init(App $a) } if (!empty($_SERVER['HTTP_ACCEPT']) && strstr($_SERVER['HTTP_ACCEPT'], 'application/atom+xml')) { - Logger::log('Directly serving XML for uri-id '.$item['uri-id'], Logger::DEBUG); + Logger::info('Directly serving XML for uri-id '.$item['uri-id']); displayShowFeed($item['uri-id'], $item['uid'], false); } diff --git a/mod/pubsub.php b/mod/pubsub.php index 1dfbd0b3dc..99e8015f19 100644 --- a/mod/pubsub.php +++ b/mod/pubsub.php @@ -59,14 +59,14 @@ function pubsub_init(App $a) $hub_challenge = Strings::escapeTags(trim($_GET['hub_challenge'] ?? '')); $hub_verify = Strings::escapeTags(trim($_GET['hub_verify_token'] ?? '')); - Logger::log('Subscription from ' . $_SERVER['REMOTE_ADDR'] . ' Mode: ' . $hub_mode . ' Nick: ' . $nick); - Logger::log('Data: ' . print_r($_GET,true), Logger::DATA); + Logger::notice('Subscription from ' . $_SERVER['REMOTE_ADDR'] . ' Mode: ' . $hub_mode . ' Nick: ' . $nick); + Logger::debug('Data: ', ['get' => $_GET]); $subscribe = (($hub_mode === 'subscribe') ? 1 : 0); $owner = DBA::selectFirst('user', ['uid'], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]); if (!DBA::isResult($owner)) { - Logger::log('Local account not found: ' . $nick); + Logger::notice('Local account not found: ' . $nick); hub_return(false, ''); } @@ -78,12 +78,12 @@ function pubsub_init(App $a) $contact = DBA::selectFirst('contact', ['id', 'poll'], $condition); if (!DBA::isResult($contact)) { - Logger::log('Contact ' . $contact_id . ' not found.'); + Logger::notice('Contact ' . $contact_id . ' not found.'); hub_return(false, ''); } if (!empty($hub_topic) && !Strings::compareLink($hub_topic, $contact['poll'])) { - Logger::log('Hub topic ' . $hub_topic . ' != ' . $contact['poll']); + Logger::notice('Hub topic ' . $hub_topic . ' != ' . $contact['poll']); hub_return(false, ''); } @@ -91,13 +91,13 @@ function pubsub_init(App $a) // Don't allow outsiders to unsubscribe us. if (($hub_mode === 'unsubscribe') && empty($hub_verify)) { - Logger::log('Bogus unsubscribe'); + Logger::notice('Bogus unsubscribe'); hub_return(false, ''); } if (!empty($hub_mode)) { Contact::update(['subhub' => $subscribe], ['id' => $contact['id']]); - Logger::log($hub_mode . ' success for contact ' . $contact_id . '.'); + Logger::notice($hub_mode . ' success for contact ' . $contact_id . '.'); } hub_return(true, $hub_challenge); } @@ -107,8 +107,8 @@ function pubsub_post(App $a) { $xml = Network::postdata(); - Logger::log('Feed arrived from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . DI::args()->getCommand() . ' with user-agent: ' . $_SERVER['HTTP_USER_AGENT']); - Logger::log('Data: ' . $xml, Logger::DATA); + Logger::notice('Feed arrived from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . DI::args()->getCommand() . ' with user-agent: ' . $_SERVER['HTTP_USER_AGENT']); + Logger::debug('Data: ' . $xml); $nick = ((DI::args()->getArgc() > 1) ? Strings::escapeTags(trim(DI::args()->getArgv()[1])) : ''); $contact_id = ((DI::args()->getArgc() > 2) ? intval(DI::args()->getArgv()[2]) : 0 ); @@ -126,10 +126,10 @@ function pubsub_post(App $a) if (!empty($author['contact-id'])) { $condition = ['id' => $author['contact-id'], 'uid' => $importer['uid'], 'subhub' => true, 'blocked' => false]; $contact = DBA::selectFirst('contact', [], $condition); - Logger::log('No record for ' . $nick .' with contact id ' . $contact_id . ' - using '.$author['contact-id'].' instead.'); + Logger::notice('No record for ' . $nick .' with contact id ' . $contact_id . ' - using '.$author['contact-id'].' instead.'); } if (!DBA::isResult($contact)) { - Logger::log('Contact ' . $author["author-link"] . ' (' . $contact_id . ') for user ' . $nick . " wasn't found - ignored. XML: " . $xml); + Logger::notice('Contact ' . $author["author-link"] . ' (' . $contact_id . ') for user ' . $nick . " wasn't found - ignored. XML: " . $xml); hub_post_return(); } } @@ -139,7 +139,7 @@ function pubsub_post(App $a) } if (!in_array($contact['rel'], [Contact::SHARING, Contact::FRIEND]) && ($contact['network'] != Protocol::FEED)) { - Logger::log('Contact ' . $contact['id'] . ' is not expected to share with us - ignored.'); + Logger::notice('Contact ' . $contact['id'] . ' is not expected to share with us - ignored.'); hub_post_return(); } @@ -149,7 +149,7 @@ function pubsub_post(App $a) hub_post_return(); } - Logger::log('Import item for ' . $nick . ' from ' . $contact['nick'] . ' (' . $contact['id'] . ')'); + Logger::notice('Import item for ' . $nick . ' from ' . $contact['nick'] . ' (' . $contact['id'] . ')'); $feedhub = ''; OStatus::import($xml, $importer, $contact, $feedhub); diff --git a/mod/pubsubhubbub.php b/mod/pubsubhubbub.php index bc90c76d66..f985bef63b 100644 --- a/mod/pubsubhubbub.php +++ b/mod/pubsubhubbub.php @@ -60,11 +60,11 @@ function pubsubhubbub_init(App $a) { } elseif ($hub_mode === 'unsubscribe') { $subscribe = 0; } else { - Logger::log("Invalid hub_mode=$hub_mode, ignoring."); + Logger::notice("Invalid hub_mode=$hub_mode, ignoring."); throw new \Friendica\Network\HTTPException\NotFoundException(); } - Logger::log("$hub_mode request from " . $_SERVER['REMOTE_ADDR']); + Logger::notice("$hub_mode request from " . $_SERVER['REMOTE_ADDR']); if (DI::args()->getArgc() > 1) { // Normally the url should now contain the nick name as last part of the url @@ -77,7 +77,7 @@ function pubsubhubbub_init(App $a) { $nick = basename($nick, '.atom'); if (!$nick) { - Logger::log('Bad hub_topic=$hub_topic, ignoring.'); + Logger::notice('Bad hub_topic=$hub_topic, ignoring.'); throw new \Friendica\Network\HTTPException\NotFoundException(); } @@ -85,7 +85,7 @@ function pubsubhubbub_init(App $a) { $condition = ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]; $owner = DBA::selectFirst('user', ['uid', 'nickname'], $condition); if (!DBA::isResult($owner)) { - Logger::log('Local account not found: ' . $nick . ' - topic: ' . $hub_topic . ' - callback: ' . $hub_callback); + Logger::notice('Local account not found: ' . $nick . ' - topic: ' . $hub_topic . ' - callback: ' . $hub_callback); throw new \Friendica\Network\HTTPException\NotFoundException(); } @@ -94,7 +94,7 @@ function pubsubhubbub_init(App $a) { 'pending' => false, 'self' => true]; $contact = DBA::selectFirst('contact', ['poll'], $condition); if (!DBA::isResult($contact)) { - Logger::log('Self contact for user ' . $owner['uid'] . ' not found.'); + Logger::notice('Self contact for user ' . $owner['uid'] . ' not found.'); throw new \Friendica\Network\HTTPException\NotFoundException(); } @@ -103,7 +103,7 @@ function pubsubhubbub_init(App $a) { $self = DI::baseUrl() . '/api/statuses/user_timeline/' . $owner['nickname'] . '.atom'; if (!Strings::compareLink($hub_topic, $contact['poll']) && !Strings::compareLink($hub_topic2, $contact['poll']) && !Strings::compareLink($hub_topic, $self)) { - Logger::log('Hub topic ' . $hub_topic . ' != ' . $contact['poll']); + Logger::notice('Hub topic ' . $hub_topic . ' != ' . $contact['poll']); throw new \Friendica\Network\HTTPException\NotFoundException(); } @@ -131,14 +131,14 @@ function pubsubhubbub_init(App $a) { // give up if the HTTP return code wasn't a success (2xx) if ($ret < 200 || $ret > 299) { - Logger::log("Subscriber verification for $hub_topic at $hub_callback returned $ret, ignoring."); + Logger::notice("Subscriber verification for $hub_topic at $hub_callback returned $ret, ignoring."); throw new \Friendica\Network\HTTPException\NotFoundException(); } // check that the correct hub_challenge code was echoed back if (trim($body) !== $hub_challenge) { - Logger::log("Subscriber did not echo back hub.challenge, ignoring."); - Logger::log("\"$hub_challenge\" != \"".trim($body)."\""); + Logger::notice("Subscriber did not echo back hub.challenge, ignoring."); + Logger::notice("\"$hub_challenge\" != \"".trim($body)."\""); throw new \Friendica\Network\HTTPException\NotFoundException(); } diff --git a/mod/redir.php b/mod/redir.php index a158f31798..e96a58b63a 100644 --- a/mod/redir.php +++ b/mod/redir.php @@ -76,7 +76,7 @@ function redir_init(App $a) { // Local user is already authenticated. redir_check_url($contact_url, $url); $target_url = $url ?: $contact_url; - Logger::log($contact['name'] . " is already authenticated. Redirecting to " . $target_url, Logger::DEBUG); + Logger::info($contact['name'] . " is already authenticated. Redirecting to " . $target_url); $a->redirect($target_url); } } @@ -93,7 +93,7 @@ function redir_init(App $a) { // Remote user is already authenticated. redir_check_url($contact_url, $url); $target_url = $url ?: $contact_url; - Logger::log($contact['name'] . " is already authenticated. Redirecting to " . $target_url, Logger::DEBUG); + Logger::info($contact['name'] . " is already authenticated. Redirecting to " . $target_url); $a->redirect($target_url); } } @@ -112,7 +112,7 @@ function redir_init(App $a) { $url .= $separator . 'zrl=' . urlencode($my_profile); } - Logger::log('redirecting to ' . $url, Logger::DEBUG); + Logger::info('redirecting to ' . $url); $a->redirect($url); } diff --git a/mod/wall_upload.php b/mod/wall_upload.php index f915954f0a..38819c9a58 100644 --- a/mod/wall_upload.php +++ b/mod/wall_upload.php @@ -38,7 +38,7 @@ use Friendica\Util\Strings; function wall_upload_post(App $a, $desktopmode = true) { - Logger::log("wall upload: starting new upload", Logger::DEBUG); + Logger::info("wall upload: starting new upload"); $r_json = (!empty($_GET['response']) && $_GET['response'] == 'json'); $album = trim($_GET['album'] ?? ''); @@ -156,8 +156,8 @@ function wall_upload_post(App $a, $desktopmode = true) $filetype = Images::getMimeTypeBySource($src, $filename, $filetype); - Logger::log("File upload src: " . $src . " - filename: " . $filename . - " - size: " . $filesize . " - type: " . $filetype, Logger::DEBUG); + Logger::info("File upload src: " . $src . " - filename: " . $filename . + " - size: " . $filesize . " - type: " . $filetype); $imagedata = @file_get_contents($src); $Image = new Image($imagedata, $filetype); @@ -183,7 +183,7 @@ function wall_upload_post(App $a, $desktopmode = true) if ($max_length > 0) { $Image->scaleDown($max_length); $filesize = strlen($Image->asString()); - Logger::log("File upload: Scaling picture to new size " . $max_length, Logger::DEBUG); + Logger::info("File upload: Scaling picture to new size " . $max_length); } $width = $Image->getWidth(); @@ -278,11 +278,11 @@ function wall_upload_post(App $a, $desktopmode = true) echo json_encode(['picture' => $picture]); exit(); } - Logger::log("upload done", Logger::DEBUG); + Logger::info("upload done"); return $picture; } - Logger::log("upload done", Logger::DEBUG); + Logger::info("upload done"); if ($r_json) { echo json_encode(['ok' => true]); diff --git a/src/BaseModule.php b/src/BaseModule.php index d7ca5798de..ced1e55c39 100644 --- a/src/BaseModule.php +++ b/src/BaseModule.php @@ -183,8 +183,8 @@ abstract class BaseModule public static function checkFormSecurityTokenRedirectOnError($err_redirect, $typename = '', $formname = 'form_security_token') { if (!self::checkFormSecurityToken($typename, $formname)) { - Logger::log('checkFormSecurityToken failed: user ' . DI::app()->getLoggedInUserNickname() . ' - form element ' . $typename); - Logger::log('checkFormSecurityToken failed: _REQUEST data: ' . print_r($_REQUEST, true), Logger::DATA); + Logger::notice('checkFormSecurityToken failed: user ' . DI::app()->getLoggedInUserNickname() . ' - form element ' . $typename); + Logger::debug('checkFormSecurityToken failed', ['request' => $_REQUEST]); notice(self::getFormSecurityStandardErrorMessage()); DI::baseUrl()->redirect($err_redirect); } @@ -193,8 +193,8 @@ abstract class BaseModule public static function checkFormSecurityTokenForbiddenOnError($typename = '', $formname = 'form_security_token') { if (!self::checkFormSecurityToken($typename, $formname)) { - Logger::log('checkFormSecurityToken failed: user ' . DI::app()->getLoggedInUserNickname() . ' - form element ' . $typename); - Logger::log('checkFormSecurityToken failed: _REQUEST data: ' . print_r($_REQUEST, true), Logger::DATA); + Logger::notice('checkFormSecurityToken failed: user ' . DI::app()->getLoggedInUserNickname() . ' - form element ' . $typename); + Logger::debug('checkFormSecurityToken failed', ['request' => $_REQUEST]); throw new \Friendica\Network\HTTPException\ForbiddenException(); } diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 06e546d614..f2e2bf92f3 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -2395,7 +2395,7 @@ class Contact } if (($network != '') && ($ret['network'] != $network)) { - Logger::log('Expected network ' . $network . ' does not match actual network ' . $ret['network']); + Logger::notice('Expected network ' . $network . ' does not match actual network ' . $ret['network']); return $result; } @@ -2545,7 +2545,7 @@ class Contact } } elseif ($protocol == Protocol::DIASPORA) { $ret = Diaspora::sendShare($owner, $contact); - Logger::log('share returns: ' . $ret); + Logger::notice('share returns: ' . $ret); } elseif ($protocol == Protocol::ACTIVITYPUB) { $activity_id = ActivityPub\Transmitter::activityIDFromContact($contact_id); if (empty($activity_id)) { @@ -2554,7 +2554,7 @@ class Contact } $ret = ActivityPub\Transmitter::sendActivity('Follow', $contact['url'], $uid, $activity_id); - Logger::log('Follow returns: ' . $ret); + Logger::notice('Follow returns: ' . $ret); } } @@ -2672,7 +2672,7 @@ class Contact } else { // send email notification to owner? if (DBA::exists('contact', ['nurl' => Strings::normaliseLink($url), 'uid' => $importer['uid'], 'pending' => true])) { - Logger::log('ignoring duplicated connection request from pending contact ' . $url); + Logger::notice('ignoring duplicated connection request from pending contact ' . $url); return null; } @@ -2791,7 +2791,7 @@ class Contact $contacts = DBA::select('contact', ['id', 'uid', 'name', 'url', 'bd'], $condition); while ($contact = DBA::fetch($contacts)) { - Logger::log('update_contact_birthday: ' . $contact['bd']); + Logger::notice('update_contact_birthday: ' . $contact['bd']); $nextbd = DateTimeFormat::utcNow('Y') . substr($contact['bd'], 4); diff --git a/src/Model/Event.php b/src/Model/Event.php index ef2b55b68c..857b6c5b88 100644 --- a/src/Model/Event.php +++ b/src/Model/Event.php @@ -230,7 +230,7 @@ class Event } DBA::delete('event', ['id' => $event_id]); - Logger::log("Deleted event ".$event_id, Logger::DEBUG); + Logger::info("Deleted event", ['id' => $event_id]); } /** diff --git a/src/Model/Item.php b/src/Model/Item.php index 285187e5fb..297506176a 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -971,7 +971,7 @@ class Item } if (!empty($item['cancel'])) { - Logger::log('post cancelled by addon.'); + Logger::notice('post cancelled by addon.'); return 0; } @@ -1885,7 +1885,7 @@ class Item foreach ($matches as $mtch) { if (Strings::compareLink($link, $mtch[1]) || Strings::compareLink($dlink, $mtch[1])) { $mention = true; - Logger::log('mention found: ' . $mtch[2]); + Logger::notice('mention found', ['mention' => $mtch[2]]); } } } @@ -2305,7 +2305,7 @@ class Item ++$expired; } DBA::close($items); - Logger::log('User ' . $uid . ": expired $expired items; expire items: $expire_items, expire notes: $expire_notes, expire starred: $expire_starred, expire photos: $expire_photos"); + Logger::notice('User ' . $uid . ": expired $expired items; expire items: $expire_items, expire notes: $expire_notes, expire starred: $expire_starred, expire photos: $expire_photos"); } public static function firstPostDate($uid, $wall = false) @@ -2354,7 +2354,7 @@ class Item $item = Post::selectFirst(self::ITEM_FIELDLIST, ['id' => $item_id]); if (!DBA::isResult($item)) { - Logger::log('like: unknown item ' . $item_id); + Logger::notice('like: unknown item', ['id' => $item_id]); return false; } diff --git a/src/Model/Mail.php b/src/Model/Mail.php index f9c197ffa0..7cd836610b 100644 --- a/src/Model/Mail.php +++ b/src/Model/Mail.php @@ -187,7 +187,7 @@ class Mail } if (!$convid) { - Logger::log('send message: conversation not found.'); + Logger::notice('send message: conversation not found.'); return -4; } @@ -291,7 +291,7 @@ class Mail } if (!$convid) { - Logger::log('send message: conversation not found.'); + Logger::notice('send message: conversation not found.'); return -4; } diff --git a/src/Model/User.php b/src/Model/User.php index 263bba99c8..7944943428 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -1517,7 +1517,7 @@ class User return false; } - Logger::log('Removing user: ' . $uid); + Logger::notice('Removing user', ['user' => $uid]); $user = DBA::selectFirst('user', [], ['uid' => $uid]); diff --git a/src/Module/Attach.php b/src/Module/Attach.php index d9a6d9f64c..a4bb9b4221 100644 --- a/src/Module/Attach.php +++ b/src/Module/Attach.php @@ -57,7 +57,7 @@ class Attach extends BaseModule $data = MAttach::getData($item); if (is_null($data)) { - Logger::log('NULL data for attachment with id ' . $item['id']); + Logger::notice('NULL data for attachment with id ' . $item['id']); throw new \Friendica\Network\HTTPException\NotFoundException(DI::l10n()->t('Item was not found.')); } diff --git a/src/Module/Register.php b/src/Module/Register.php index d93c8754fe..e4a417fbaf 100644 --- a/src/Module/Register.php +++ b/src/Module/Register.php @@ -82,7 +82,7 @@ class Register extends BaseModule if ($max_dailies) { $count = DBA::count('user', ['`register_date` > UTC_TIMESTAMP - INTERVAL 1 day']); if ($count >= $max_dailies) { - Logger::log('max daily registrations exceeded.'); + Logger::notice('max daily registrations exceeded.'); notice(DI::l10n()->t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.')); return ''; } diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 8c511c2cd5..6e35ae23a9 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -929,21 +929,21 @@ class DFRN { if (!$public_batch) { if (empty($contact['addr'])) { - Logger::log('Empty contact handle for ' . $contact['id'] . ' - ' . $contact['url'] . ' - trying to update it.'); + Logger::notice('Empty contact handle for ' . $contact['id'] . ' - ' . $contact['url'] . ' - trying to update it.'); if (Contact::updateFromProbe($contact['id'])) { $new_contact = DBA::selectFirst('contact', ['addr'], ['id' => $contact['id']]); $contact['addr'] = $new_contact['addr']; } if (empty($contact['addr'])) { - Logger::log('Unable to find contact handle for ' . $contact['id'] . ' - ' . $contact['url']); + Logger::notice('Unable to find contact handle for ' . $contact['id'] . ' - ' . $contact['url']); return -21; } } $fcontact = FContact::getByURL($contact['addr']); if (empty($fcontact)) { - Logger::log('Unable to find contact details for ' . $contact['id'] . ' - ' . $contact['addr']); + Logger::notice('Unable to find contact details for ' . $contact['id'] . ' - ' . $contact['addr']); return -22; } $pubkey = $fcontact['pubkey']; @@ -976,7 +976,7 @@ class DFRN $curl_stat = $postResult->getReturnCode(); if (empty($curl_stat) || empty($xml)) { - Logger::log('Empty answer from ' . $contact['id'] . ' - ' . $dest_url); + Logger::notice('Empty answer from ' . $contact['id'] . ' - ' . $dest_url); return -9; // timed out } @@ -985,8 +985,8 @@ class DFRN } if (strpos($xml, 'message)) { - Logger::log('Transmit to ' . $dest_url . ' returned status '.$res->status.' - '.$res->message, Logger::DEBUG); + Logger::info('Transmit to ' . $dest_url . ' returned status '.$res->status.' - '.$res->message); } return intval($res->status); @@ -1088,12 +1088,12 @@ class DFRN } if (empty($author['avatar'])) { - Logger::log('Empty author: ' . $xml); + Logger::notice('Empty author: ' . $xml); $author['avatar'] = ''; } if (DBA::isResult($contact_old) && !$onlyfetch) { - Logger::log("Check if contact details for contact " . $contact_old["id"] . " (" . $contact_old["nick"] . ") have to be updated.", Logger::DEBUG); + Logger::info("Check if contact details for contact " . $contact_old["id"] . " (" . $contact_old["nick"] . ") have to be updated."); $poco = ["url" => $contact_old["url"], "network" => $contact_old["network"]]; @@ -1154,7 +1154,7 @@ class DFRN // If the "hide" element is present then the profile isn't searchable. $hide = intval(XML::getFirstNodeValue($xpath, $element . "/dfrn:hide/text()", $context) == "true"); - Logger::log("Hidden status for contact " . $contact_old["url"] . ": " . $hide, Logger::DEBUG); + Logger::info("Hidden status for contact " . $contact_old["url"] . ": " . $hide); // If the contact isn't searchable then set the contact to "hidden". // Problem: This can be manually overridden by the user. @@ -1295,7 +1295,7 @@ class DFRN */ private static function processMail($xpath, $mail, $importer) { - Logger::log("Processing mails"); + Logger::notice("Processing mails"); $msg = []; $msg["uid"] = $importer["importer_uid"]; @@ -1397,7 +1397,7 @@ class DFRN */ private static function processRelocation($xpath, $relocation, $importer) { - Logger::log("Processing relocations"); + Logger::notice("Processing relocations"); /// @TODO Rewrite this to one statement $relocate = []; @@ -1444,7 +1444,7 @@ class DFRN Contact::updateAvatar($importer["id"], $relocate["avatar"], true); - Logger::log('Contacts are updated.'); + Logger::notice('Contacts are updated.'); /// @TODO /// merge with current record, current contents have priority @@ -1505,7 +1505,7 @@ class DFRN if ($importer["page-flags"] == User::PAGE_FLAGS_COMMUNITY || $importer["page-flags"] == User::PAGE_FLAGS_PRVGROUP) { $sql_extra = ""; $community = true; - Logger::log("possible community action"); + Logger::notice("possible community action"); } else { $sql_extra = " AND `self` AND `wall`"; } @@ -1525,7 +1525,7 @@ class DFRN */ if ($is_a_remote_action && $community && (!$parent["forum_mode"]) && (!$parent["wall"])) { $is_a_remote_action = false; - Logger::log("not a community action"); + Logger::notice("not a community action"); } if ($is_a_remote_action) { @@ -1606,7 +1606,7 @@ class DFRN */ private static function processVerbs($entrytype, $importer, &$item, &$is_like) { - Logger::log("Process verb ".$item["verb"]." and object-type ".$item["object-type"]." for entrytype ".$entrytype, Logger::DEBUG); + Logger::info("Process verb ".$item["verb"]." and object-type ".$item["object-type"]." for entrytype ".$entrytype); if (($entrytype == DFRN::TOP_LEVEL) && !empty($importer['id'])) { // The filling of the the "contact" variable is done for legcy reasons @@ -1618,22 +1618,22 @@ class DFRN // Big question: Do we need these functions? They were part of the "consume_feed" function. // This function once was responsible for DFRN and OStatus. if ($activity->match($item["verb"], Activity::FOLLOW)) { - Logger::log("New follower"); + Logger::notice("New follower"); Contact::addRelationship($importer, $contact, $item); return false; } if ($activity->match($item["verb"], Activity::UNFOLLOW)) { - Logger::log("Lost follower"); + Logger::notice("Lost follower"); Contact::removeFollower($contact); return false; } if ($activity->match($item["verb"], Activity::REQ_FRIEND)) { - Logger::log("New friend request"); + Logger::notice("New friend request"); Contact::addRelationship($importer, $contact, $item, true); return false; } if ($activity->match($item["verb"], Activity::UNFRIEND)) { - Logger::log("Lost sharer"); + Logger::notice("Lost sharer"); Contact::removeSharer($importer, $contact, $item); return false; } @@ -1678,7 +1678,7 @@ class DFRN $item_tag = Post::selectFirst(['id', 'uri-id'], ['uri' => $xt->id, 'uid' => $importer["importer_uid"]]); if (!DBA::isResult($item_tag)) { - Logger::log("Query failed to execute, no result returned in " . __FUNCTION__); + Logger::notice("Query failed to execute, no result returned in " . __FUNCTION__); return false; } @@ -1765,7 +1765,7 @@ class DFRN */ private static function processEntry($header, $xpath, $entry, $importer, $xml, $protocol) { - Logger::log("Processing entries"); + Logger::notice("Processing entries"); $item = $header; @@ -1783,7 +1783,7 @@ class DFRN ); // Is there an existing item? if (DBA::isResult($current) && !self::isEditedTimestampNewer($current, $item)) { - Logger::log("Item ".$item["uri"]." (".$item['edited'].") already existed.", Logger::DEBUG); + Logger::info("Item ".$item["uri"]." (".$item['edited'].") already existed."); return; } @@ -1993,10 +1993,10 @@ class DFRN // Is it an event? if (($item["object-type"] == Activity\ObjectType::EVENT) && !$owner_unknown) { - Logger::log("Item ".$item["uri"]." seems to contain an event.", Logger::DEBUG); + Logger::info("Item ".$item["uri"]." seems to contain an event."); $ev = Event::fromBBCode($item["body"]); if ((!empty($ev['desc']) || !empty($ev['summary'])) && !empty($ev['start'])) { - Logger::log("Event in item ".$item["uri"]." was found.", Logger::DEBUG); + Logger::info("Event in item ".$item["uri"]." was found."); $ev["cid"] = $importer["id"]; $ev["uid"] = $importer["importer_uid"]; $ev["uri"] = $item["uri"]; @@ -2024,13 +2024,13 @@ class DFRN } if (!self::processVerbs($entrytype, $importer, $item, $is_like)) { - Logger::log("Exiting because 'processVerbs' told us so", Logger::DEBUG); + Logger::info("Exiting because 'processVerbs' told us so"); return; } // This check is done here to be able to receive connection requests in "processVerbs" if (($entrytype == DFRN::TOP_LEVEL) && $owner_unknown) { - Logger::log("Item won't be stored because user " . $importer["importer_uid"] . " doesn't follow " . $item["owner-link"] . ".", Logger::DEBUG); + Logger::info("Item won't be stored because user " . $importer["importer_uid"] . " doesn't follow " . $item["owner-link"] . "."); return; } @@ -2038,9 +2038,9 @@ class DFRN // Update content if 'updated' changes if (DBA::isResult($current)) { if (self::updateContent($current, $item, $importer, $entrytype)) { - Logger::log("Item ".$item["uri"]." was updated.", Logger::DEBUG); + Logger::info("Item ".$item["uri"]." was updated."); } else { - Logger::log("Item " . $item["uri"] . " already existed.", Logger::DEBUG); + Logger::info("Item " . $item["uri"] . " already existed."); } return; } @@ -2053,7 +2053,7 @@ class DFRN $posted_id = Item::insert($item); if ($posted_id) { - Logger::log("Reply from contact ".$item["contact-id"]." was stored with id ".$posted_id, Logger::DEBUG); + Logger::info("Reply from contact ".$item["contact-id"]." was stored with id ".$posted_id); if ($item['uid'] == 0) { Item::distribute($posted_id); @@ -2063,7 +2063,7 @@ class DFRN } } else { // $entrytype == DFRN::TOP_LEVEL if (($importer["uid"] == 0) && ($importer["importer_uid"] != 0)) { - Logger::log("Contact ".$importer["id"]." isn't known to user ".$importer["importer_uid"].". The post will be ignored.", Logger::DEBUG); + Logger::info("Contact ".$importer["id"]." isn't known to user ".$importer["importer_uid"].". The post will be ignored."); return; } if (!Strings::compareLink($item["owner-link"], $importer["url"])) { @@ -2073,13 +2073,13 @@ class DFRN * the tgroup delivery code called from Item::insert will correct it if it's a forum, * but we're going to unconditionally correct it here so that the post will always be owned by our contact. */ - Logger::log('Correcting item owner.', Logger::DEBUG); + Logger::info('Correcting item owner.'); $item["owner-link"] = $importer["url"]; $item["owner-id"] = Contact::getIdForURL($importer["url"], 0); } if (($importer["rel"] == Contact::FOLLOWER) && (!self::tgroupCheck($importer["importer_uid"], $item))) { - Logger::log("Contact ".$importer["id"]." is only follower and tgroup check was negative.", Logger::DEBUG); + Logger::info("Contact ".$importer["id"]." is only follower and tgroup check was negative."); return; } @@ -2093,7 +2093,7 @@ class DFRN $posted_id = $notify; } - Logger::log("Item was stored with id ".$posted_id, Logger::DEBUG); + Logger::info("Item was stored with id ".$posted_id); if ($item['uid'] == 0) { Item::distribute($posted_id); @@ -2118,7 +2118,7 @@ class DFRN */ private static function processDeletion($xpath, $deletion, $importer) { - Logger::log("Processing deletions"); + Logger::notice("Processing deletions"); $uri = null; foreach ($deletion->attributes as $attributes) { @@ -2134,7 +2134,7 @@ class DFRN $condition = ['uri' => $uri, 'uid' => $importer["importer_uid"]]; $item = Post::selectFirst(['id', 'parent', 'contact-id', 'uri-id', 'deleted', 'gravity'], $condition); if (!DBA::isResult($item)) { - Logger::log("Item with uri " . $uri . " for user " . $importer["importer_uid"] . " wasn't found.", Logger::DEBUG); + Logger::info("Item with uri " . $uri . " for user " . $importer["importer_uid"] . " wasn't found."); return; } @@ -2145,7 +2145,7 @@ class DFRN // When it is a starting post it has to belong to the person that wants to delete it if (($item['gravity'] == GRAVITY_PARENT) && ($item['contact-id'] != $importer["id"])) { - Logger::log("Item with uri " . $uri . " don't belong to contact " . $importer["id"] . " - ignoring deletion.", Logger::DEBUG); + Logger::info("Item with uri " . $uri . " don't belong to contact " . $importer["id"] . " - ignoring deletion."); return; } @@ -2153,7 +2153,7 @@ class DFRN if (($item['gravity'] != GRAVITY_PARENT) && ($item['contact-id'] != $importer["id"])) { $condition = ['id' => $item['parent'], 'contact-id' => $importer["id"]]; if (!Post::exists($condition)) { - Logger::log("Item with uri " . $uri . " wasn't found or mustn't be deleted by contact " . $importer["id"] . " - ignoring deletion.", Logger::DEBUG); + Logger::info("Item with uri " . $uri . " wasn't found or mustn't be deleted by contact " . $importer["id"] . " - ignoring deletion."); return; } } @@ -2162,7 +2162,7 @@ class DFRN return; } - Logger::log('deleting item '.$item['id'].' uri='.$uri, Logger::DEBUG); + Logger::info('deleting item '.$item['id'].' uri='.$uri); Item::markForDeletion(['id' => $item['id']]); } @@ -2224,7 +2224,7 @@ class DFRN self::fetchauthor($xpath, $doc->firstChild, $importer, "dfrn:owner", false, $xml); } - Logger::log("Import DFRN message for user " . $importer["importer_uid"] . " from contact " . $importer["id"], Logger::DEBUG); + Logger::info("Import DFRN message for user " . $importer["importer_uid"] . " from contact " . $importer["id"]); if (!empty($importer['gsid']) && ($protocol == Conversation::PARCEL_DIASPORA_DFRN)) { GServer::setProtocol($importer['gsid'], Post\DeliveryData::DFRN); @@ -2307,7 +2307,7 @@ class DFRN self::processEntry($header, $xpath, $entry, $importer, $xml, $protocol); } - Logger::log("Import done for user " . $importer["importer_uid"] . " from contact " . $importer["id"], Logger::DEBUG); + Logger::info("Import done for user " . $importer["importer_uid"] . " from contact " . $importer["id"]); return 200; } @@ -2357,7 +2357,7 @@ class DFRN foreach ($matches as $mtch) { if (Strings::compareLink($link, $mtch[1]) || Strings::compareLink($dlink, $mtch[1])) { $mention = true; - Logger::log('mention found: ' . $mtch[2]); + Logger::notice('mention found: ' . $mtch[2]); } } } diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index 7e17ab9f98..277644dcc9 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -212,7 +212,7 @@ class OStatus Contact::update($contact, ['id' => $contact["id"]], $current); if (!empty($author["author-avatar"]) && ($author["author-avatar"] != $current['avatar'])) { - Logger::log("Update profile picture for contact ".$contact["id"], Logger::DEBUG); + Logger::info("Update profile picture for contact ".$contact["id"]); Contact::updateAvatar($contact["id"], $author["author-avatar"]); } @@ -336,7 +336,7 @@ class OStatus self::$conv_list = []; } - Logger::log('Import OStatus message for user ' . $importer['uid'], Logger::DEBUG); + Logger::info('Import OStatus message for user ' . $importer['uid']); if ($xml == "") { return false; @@ -362,7 +362,7 @@ class OStatus foreach ($hub_attributes as $hub_attribute) { if ($hub_attribute->name == "href") { $hub = $hub_attribute->textContent; - Logger::log("Found hub ".$hub, Logger::DEBUG); + Logger::info("Found hub ".$hub); } } } @@ -440,27 +440,27 @@ class OStatus if (in_array($item["verb"], [Activity::O_UNFAVOURITE, Activity::UNFAVORITE])) { // Ignore "Unfavorite" message - Logger::log("Ignore unfavorite message ".print_r($item, true), Logger::DEBUG); + Logger::info("Ignore unfavorite message ", ['item' => $item]); continue; } // Deletions come with the same uri, so we check for duplicates after processing deletions if (Post::exists(['uid' => $importer["uid"], 'uri' => $item["uri"]])) { - Logger::log('Post with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', Logger::DEBUG); + Logger::info('Post with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.'); continue; } else { - Logger::log('Processing post with URI '.$item["uri"].' for user '.$importer["uid"].'.', Logger::DEBUG); + Logger::info('Processing post with URI '.$item["uri"].' for user '.$importer["uid"].'.'); } if ($item["verb"] == Activity::JOIN) { // ignore "Join" messages - Logger::log("Ignore join message ".print_r($item, true), Logger::DEBUG); + Logger::info("Ignore join message ", ['item' => $item]); continue; } if ($item["verb"] == "http://mastodon.social/schema/1.0/block") { // ignore mastodon "block" messages - Logger::log("Ignore block message ".print_r($item, true), Logger::DEBUG); + Logger::info("Ignore block message ", ['item' => $item]); continue; } @@ -477,7 +477,7 @@ class OStatus if ($item["verb"] == Activity::FAVORITE) { $orig_uri = $xpath->query("activity:object/atom:id", $entry)->item(0)->nodeValue; - Logger::log("Favorite ".$orig_uri." ".print_r($item, true)); + Logger::notice("Favorite", ['uri' => $orig_uri, 'item' => $item]); $item["verb"] = Activity::LIKE; $item["thr-parent"] = $orig_uri; @@ -487,7 +487,7 @@ class OStatus // http://activitystrea.ms/schema/1.0/rsvp-yes if (!in_array($item["verb"], [Activity::POST, Activity::LIKE, Activity::SHARE])) { - Logger::log("Unhandled verb ".$item["verb"]." ".print_r($item, true), Logger::DEBUG); + Logger::info("Unhandled verb", ['verb' => $item["verb"], 'item' => $item]); } self::processPost($xpath, $entry, $item, $importer); @@ -501,10 +501,10 @@ class OStatus // If not, then it depends on this setting $valid = ((self::$itemlist[0]['uid'] == 0) || !DI::pConfig()->get(self::$itemlist[0]['uid'], 'system', 'accept_only_sharer', false)); if ($valid) { - Logger::log("Item with uri ".self::$itemlist[0]['uri']." will be imported due to the system settings.", Logger::DEBUG); + Logger::info("Item with uri ".self::$itemlist[0]['uri']." will be imported due to the system settings."); } } else { - Logger::log("Item with uri ".self::$itemlist[0]['uri']." belongs to a contact (".self::$itemlist[0]['contact-id']."). It will be imported.", Logger::DEBUG); + Logger::info("Item with uri ".self::$itemlist[0]['uri']." belongs to a contact (".self::$itemlist[0]['contact-id']."). It will be imported."); } if ($valid) { // Never post a thread when the only interaction by our contact was a like @@ -516,7 +516,7 @@ class OStatus } } if ($valid) { - Logger::log("Item with uri ".self::$itemlist[0]['uri']." will be imported since the thread contains posts or shares.", Logger::DEBUG); + Logger::info("Item with uri ".self::$itemlist[0]['uri']." will be imported since the thread contains posts or shares."); } } } else { @@ -535,18 +535,18 @@ class OStatus foreach (self::$itemlist as $item) { $found = Post::exists(['uid' => $importer["uid"], 'uri' => $item["uri"]]); if ($found) { - Logger::log("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already exists.", Logger::DEBUG); + Logger::info("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already exists."); } elseif ($item['contact-id'] < 0) { - Logger::log("Item with uri ".$item["uri"]." is from a blocked contact.", Logger::DEBUG); + Logger::info("Item with uri ".$item["uri"]." is from a blocked contact."); } else { $ret = Item::insert($item); - Logger::log("Item with uri ".$item["uri"]." for user ".$importer["uid"].' stored. Return value: '.$ret); + Logger::notice("Item with uri ".$item["uri"]." for user ".$importer["uid"].' stored. Return value: '.$ret); } } } self::$itemlist = []; } - Logger::log('Processing done for post with URI '.$item["uri"].' for user '.$importer["uid"].'.', Logger::DEBUG); + Logger::info('Processing done for post with URI '.$item["uri"].' for user '.$importer["uid"].'.'); } return true; } @@ -562,13 +562,13 @@ class OStatus { $condition = ['uid' => $item['uid'], 'author-id' => $item['author-id'], 'uri' => $item['uri']]; if (!Post::exists($condition)) { - Logger::log('Item from '.$item['author-link'].' with uri '.$item['uri'].' for user '.$item['uid']." wasn't found. We don't delete it."); + Logger::notice('Item from '.$item['author-link'].' with uri '.$item['uri'].' for user '.$item['uid']." wasn't found. We don't delete it."); return; } Item::markForDeletion($condition); - Logger::log('Deleted item with uri '.$item['uri'].' for user '.$item['uid']); + Logger::notice('Deleted item with uri '.$item['uri'].' for user '.$item['uid']); } /** @@ -697,7 +697,7 @@ class OStatus self::fetchRelated($related, $item["thr-parent"], $importer); } } else { - Logger::log('Reply with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', Logger::DEBUG); + Logger::info('Reply with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.'); } } else { $item["thr-parent"] = $item["uri"]; @@ -845,7 +845,7 @@ class OStatus $conv_data['source'] = $doc2->saveXML(); - Logger::log('Store conversation data for uri '.$conv_data['uri'], Logger::DEBUG); + Logger::info('Store conversation data for uri '.$conv_data['uri']); Conversation::insert($conv_data); } } @@ -868,7 +868,7 @@ class OStatus Conversation::PARCEL_DIASPORA_DFRN, Conversation::PARCEL_LEGACY_DFRN, Conversation::PARCEL_LOCAL_DFRN, Conversation::PARCEL_DIRECT, Conversation::PARCEL_SALMON]]; if (DBA::exists('conversation', $condition)) { - Logger::log('Conversation '.$item['uri'].' is already stored.', Logger::DEBUG); + Logger::info('Conversation '.$item['uri'].' is already stored.'); return; } @@ -889,7 +889,7 @@ class OStatus $item["source"] = $xml; $item["direction"] = Conversation::PULL; - Logger::log('Conversation '.$item['uri'].' is now fetched.', Logger::DEBUG); + Logger::info('Conversation '.$item['uri'].' is now fetched.'); } /** @@ -912,11 +912,11 @@ class OStatus $stored = true; $xml = $conversation['source']; if (self::process($xml, $importer, $contact, $hub, $stored, false, Conversation::PULL)) { - Logger::log('Got valid cached XML for URI '.$related_uri, Logger::DEBUG); + Logger::info('Got valid cached XML for URI '.$related_uri); return; } if ($conversation['protocol'] == Conversation::PARCEL_SALMON) { - Logger::log('Delete invalid cached XML for URI '.$related_uri, Logger::DEBUG); + Logger::info('Delete invalid cached XML for URI '.$related_uri); DBA::delete('conversation', ['item-uri' => $related_uri]); } } @@ -932,7 +932,7 @@ class OStatus if ($curlResult->inHeader('Content-Type') && in_array('application/atom+xml', $curlResult->getHeader('Content-Type'))) { - Logger::log('Directly fetched XML for URI ' . $related_uri, Logger::DEBUG); + Logger::info('Directly fetched XML for URI ' . $related_uri); $xml = $curlResult->getBody(); } @@ -957,7 +957,7 @@ class OStatus $curlResult = DI::httpClient()->get($atom_file); if ($curlResult->isSuccess()) { - Logger::log('Fetched XML for URI ' . $related_uri, Logger::DEBUG); + Logger::info('Fetched XML for URI ' . $related_uri); $xml = $curlResult->getBody(); } } @@ -969,7 +969,7 @@ class OStatus $curlResult = DI::httpClient()->get(str_replace('/notice/', '/api/statuses/show/', $related) . '.atom'); if ($curlResult->isSuccess()) { - Logger::log('GNU Social workaround to fetch XML for URI ' . $related_uri, Logger::DEBUG); + Logger::info('GNU Social workaround to fetch XML for URI ' . $related_uri); $xml = $curlResult->getBody(); } } @@ -980,7 +980,7 @@ class OStatus $curlResult = DI::httpClient()->get(str_replace('/notice/', '/api/statuses/show/', $related_guess) . '.atom'); if ($curlResult->isSuccess()) { - Logger::log('GNU Social workaround 2 to fetch XML for URI ' . $related_uri, Logger::DEBUG); + Logger::info('GNU Social workaround 2 to fetch XML for URI ' . $related_uri); $xml = $curlResult->getBody(); } } @@ -991,7 +991,7 @@ class OStatus $conversation = DBA::selectFirst('conversation', ['source'], $condition); if (DBA::isResult($conversation)) { $stored = true; - Logger::log('Got cached XML from conversation for URI '.$related_uri, Logger::DEBUG); + Logger::info('Got cached XML from conversation for URI '.$related_uri); $xml = $conversation['source']; } } @@ -999,7 +999,7 @@ class OStatus if ($xml != '') { self::process($xml, $importer, $contact, $hub, $stored, false, Conversation::PULL); } else { - Logger::log("XML couldn't be fetched for URI: ".$related_uri." - href: ".$related, Logger::DEBUG); + Logger::info("XML couldn't be fetched for URI: ".$related_uri." - href: ".$related); } return; } @@ -1536,7 +1536,7 @@ class OStatus private static function likeEntry(DOMDocument $doc, array $item, array $owner, $toplevel) { if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item["author-link"]) != Strings::normaliseLink($owner["url"]))) { - Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", Logger::DEBUG); + Logger::info("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting."); } $entry = self::entryHeader($doc, $owner, $item, $toplevel); @@ -1685,7 +1685,7 @@ class OStatus private static function noteEntry(DOMDocument $doc, array $item, array $owner, $toplevel) { if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item["author-link"]) != Strings::normaliseLink($owner["url"]))) { - Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", Logger::DEBUG); + Logger::info("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting."); } if (!$toplevel) { @@ -1983,7 +1983,7 @@ class OStatus if ((time() - strtotime($owner['last-item'])) < 15*60) { $result = DI::cache()->get($cachekey); if (!$nocache && !is_null($result)) { - Logger::log('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created . ' (cached)', Logger::DEBUG); + Logger::info('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created . ' (cached)'); $last_update = $result['last_update']; return $result['feed']; } @@ -2048,7 +2048,7 @@ class OStatus $msg = ['feed' => $feeddata, 'last_update' => $last_update]; DI::cache()->set($cachekey, $msg, Duration::QUARTER_HOUR); - Logger::log('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created, Logger::DEBUG); + Logger::info('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created); return $feeddata; } diff --git a/src/Protocol/Salmon.php b/src/Protocol/Salmon.php index 95bddcd655..ebb9f1776d 100644 --- a/src/Protocol/Salmon.php +++ b/src/Protocol/Salmon.php @@ -46,7 +46,7 @@ class Salmon { $ret = []; - Logger::log('Fetching salmon key for '.$uri); + Logger::notice('Fetching salmon key for '.$uri); $arr = Probe::lrdd($uri); @@ -116,12 +116,12 @@ class Salmon } if (!$owner['sprvkey']) { - Logger::log(sprintf("user '%s' (%d) does not have a salmon private key. Send failed.", + Logger::notice(sprintf("user '%s' (%d) does not have a salmon private key. Send failed.", $owner['name'], $owner['uid'])); return; } - Logger::log('slapper called for '.$url.'. Data: ' . $slap); + Logger::notice('slapper called for '.$url.'. Data: ' . $slap); // create a magic envelope @@ -165,7 +165,7 @@ class Salmon // check for success, e.g. 2xx if ($return_code > 299) { - Logger::log('GNU Social salmon failed. Falling back to compliant mode'); + Logger::notice('GNU Social salmon failed. Falling back to compliant mode'); // Now try the compliant mode that normally isn't used for GNU Social $xmldata = ["me:env" => ["me:data" => $data, @@ -188,7 +188,7 @@ class Salmon } if ($return_code > 299) { - Logger::log('compliant salmon failed. Falling back to old status.net'); + Logger::notice('compliant salmon failed. Falling back to old status.net'); // Last try. This will most likely fail as well. $xmldata = ["me:env" => ["me:data" => $data, @@ -209,7 +209,7 @@ class Salmon $return_code = $postResult->getReturnCode(); } - Logger::log('slapper for '.$url.' returned ' . $return_code); + Logger::notice('slapper for '.$url.' returned ' . $return_code); if (! $return_code) { return -1; diff --git a/src/Util/Crypto.php b/src/Util/Crypto.php index b3ae2d69b8..5f2fee3be8 100644 --- a/src/Util/Crypto.php +++ b/src/Util/Crypto.php @@ -136,7 +136,7 @@ class Crypto $result = openssl_pkey_new($openssl_options); if (empty($result)) { - Logger::log('new_keypair: failed'); + Logger::notice('new_keypair: failed'); return false; } @@ -261,7 +261,7 @@ class Crypto private static function encapsulateOther($data, $pubkey, $alg) { if (!$pubkey) { - Logger::log('no key. data: '.$data); + Logger::notice('no key. data: '.$data); } $fn = 'encrypt' . strtoupper($alg); if (method_exists(__CLASS__, $fn)) { @@ -303,7 +303,7 @@ class Crypto private static function encapsulateAes($data, $pubkey) { if (!$pubkey) { - Logger::log('aes_encapsulate: no key. data: ' . $data); + Logger::notice('aes_encapsulate: no key. data: ' . $data); } $key = random_bytes(32); @@ -314,7 +314,7 @@ class Crypto // log the offending call so we can track it down if (!openssl_public_encrypt($key, $k, $pubkey)) { $x = debug_backtrace(); - Logger::log('aes_encapsulate: RSA failed. ' . print_r($x[0], true)); + Logger::notice('aes_encapsulate: RSA failed.', ['data' => $x[0]]); } $result['alg'] = 'aes256cbc'; diff --git a/src/Util/DateTimeFormat.php b/src/Util/DateTimeFormat.php index fdb49dabdc..cf3216a152 100644 --- a/src/Util/DateTimeFormat.php +++ b/src/Util/DateTimeFormat.php @@ -157,7 +157,7 @@ class DateTimeFormat try { $d = new DateTime($s, $from_obj); } catch (Exception $e) { - Logger::log('DateTimeFormat::convert: exception: ' . $e->getMessage()); + Logger::notice('DateTimeFormat::convert: exception: ' . $e->getMessage()); $d = new DateTime('now', $from_obj); } diff --git a/src/Util/HTTPSignature.php b/src/Util/HTTPSignature.php index 89cb0452a3..f11dbcceb4 100644 --- a/src/Util/HTTPSignature.php +++ b/src/Util/HTTPSignature.php @@ -80,7 +80,7 @@ class HTTPSignature $sig_block = self::parseSigheader($headers['authorization']); if (!$sig_block) { - Logger::log('no signature provided.'); + Logger::notice('no signature provided.'); return $result; } @@ -110,7 +110,7 @@ class HTTPSignature $key = $key($sig_block['keyId']); } - Logger::log('Got keyID ' . $sig_block['keyId'], Logger::DEBUG); + Logger::info('Got keyID ' . $sig_block['keyId']); if (!$key) { return $result; @@ -118,7 +118,7 @@ class HTTPSignature $x = Crypto::rsaVerify($signed_data, $sig_block['signature'], $key, $algorithm); - Logger::log('verified: ' . $x, Logger::DEBUG); + Logger::info('verified: ' . $x); if (!$x) { return $result; @@ -308,7 +308,7 @@ class HTTPSignature $postResult = DI::httpClient()->post($target, $content, $headers); $return_code = $postResult->getReturnCode(); - Logger::log('Transmit to ' . $target . ' returned ' . $return_code, Logger::DEBUG); + Logger::info('Transmit to ' . $target . ' returned ' . $return_code); $success = ($return_code >= 200) && ($return_code <= 299); @@ -459,7 +459,7 @@ class HTTPSignature } $return_code = $curlResult->getReturnCode(); - Logger::log('Fetched for user ' . $uid . ' from ' . $request . ' returned ' . $return_code, Logger::DEBUG); + Logger::info('Fetched for user ' . $uid . ' from ' . $request . ' returned ' . $return_code); return $curlResult; } @@ -604,7 +604,7 @@ class HTTPSignature if (in_array('date', $sig_block['headers'])) { $diff = abs(strtotime($headers['date']) - time()); if ($diff > 300) { - Logger::log("Header date '" . $headers['date'] . "' is with " . $diff . " seconds out of the 300 second frame. The signature is invalid."); + Logger::notice("Header date '" . $headers['date'] . "' is with " . $diff . " seconds out of the 300 second frame. The signature is invalid."); return false; } $hasGoodSignedContent = true; diff --git a/src/Util/Network.php b/src/Util/Network.php index 0b10687c9d..9c7b6a8af8 100644 --- a/src/Util/Network.php +++ b/src/Util/Network.php @@ -268,7 +268,7 @@ class Network $avatar['url'] = DI::baseUrl() . Contact::DEFAULT_AVATAR_PHOTO; } - Logger::log('Avatar: ' . $avatar['email'] . ' ' . $avatar['url'], Logger::DEBUG); + Logger::info('Avatar: ' . $avatar['email'] . ' ' . $avatar['url']); return $avatar['url']; } diff --git a/src/Util/Strings.php b/src/Util/Strings.php index 196718654d..2f27e4a5ff 100644 --- a/src/Util/Strings.php +++ b/src/Util/Strings.php @@ -284,7 +284,7 @@ class Strings public static function base64UrlDecode($s) { if (is_array($s)) { - Logger::log('base64url_decode: illegal input: ' . print_r(debug_backtrace(), true)); + Logger::notice('base64url_decode: illegal input: ', ['backtrace' => debug_backtrace()]); return $s; } diff --git a/src/Util/XML.php b/src/Util/XML.php index 7b4539ba8c..df3e913f56 100644 --- a/src/Util/XML.php +++ b/src/Util/XML.php @@ -268,7 +268,7 @@ class XML } if (!function_exists('xml_parser_create')) { - Logger::log('Xml::toArray: parser function missing'); + Logger::notice('Xml::toArray: parser function missing'); return []; } @@ -283,7 +283,7 @@ class XML } if (! $parser) { - Logger::log('Xml::toArray: xml_parser_create: no resource'); + Logger::notice('Xml::toArray: xml_parser_create: no resource'); return []; } @@ -295,9 +295,9 @@ class XML @xml_parser_free($parser); if (! $xml_values) { - Logger::log('Xml::toArray: libxml: parse error: ' . $contents, Logger::DATA); + Logger::debug('Xml::toArray: libxml: parse error: ' . $contents); foreach (libxml_get_errors() as $err) { - Logger::log('libxml: parse: ' . $err->code . " at " . $err->line . ":" . $err->column . " : " . $err->message, Logger::DATA); + Logger::debug('libxml: parse: ' . $err->code . " at " . $err->line . ":" . $err->column . " : " . $err->message); } libxml_clear_errors(); return; diff --git a/src/Worker/CheckVersion.php b/src/Worker/CheckVersion.php index 6f764a72db..134ddaabad 100644 --- a/src/Worker/CheckVersion.php +++ b/src/Worker/CheckVersion.php @@ -35,7 +35,7 @@ class CheckVersion { public static function execute() { - Logger::log('checkversion: start'); + Logger::notice('checkversion: start'); $checkurl = DI::config()->get('system', 'check_new_version_url', 'none'); @@ -51,15 +51,15 @@ class CheckVersion // don't check return; } - Logger::log("Checking VERSION from: ".$checked_url, Logger::DEBUG); + Logger::info("Checking VERSION from: ".$checked_url); // fetch the VERSION file $gitversion = DBA::escape(trim(DI::httpClient()->fetch($checked_url))); - Logger::log("Upstream VERSION is: ".$gitversion, Logger::DEBUG); + Logger::notice("Upstream VERSION is: ".$gitversion); DI::config()->set('system', 'git_friendica_version', $gitversion); - Logger::log('checkversion: end'); + Logger::notice('checkversion: end'); return; } diff --git a/src/Worker/Directory.php b/src/Worker/Directory.php index 3dcaa7205b..7b098bc948 100644 --- a/src/Worker/Directory.php +++ b/src/Worker/Directory.php @@ -51,7 +51,7 @@ class Directory Hook::callAll('globaldir_update', $arr); - Logger::log('Updating directory: ' . $arr['url'], Logger::DEBUG); + Logger::info('Updating directory: ' . $arr['url']); if (strlen($arr['url'])) { DI::httpClient()->fetch($dir . '?url=' . bin2hex($arr['url'])); } diff --git a/src/Worker/ProfileUpdate.php b/src/Worker/ProfileUpdate.php index e9e9afe8d2..d353b55100 100644 --- a/src/Worker/ProfileUpdate.php +++ b/src/Worker/ProfileUpdate.php @@ -41,7 +41,7 @@ class ProfileUpdate { $inboxes = ActivityPub\Transmitter::fetchTargetInboxesforUser($uid); foreach ($inboxes as $inbox => $receivers) { - Logger::log('Profile update for user ' . $uid . ' to ' . $inbox .' via ActivityPub', Logger::DEBUG); + Logger::info('Profile update for user ' . $uid . ' to ' . $inbox .' via ActivityPub'); Worker::add(['priority' => $a->getQueueValue('priority'), 'created' => $a->getQueueValue('created'), 'dont_fork' => true], 'APDelivery', Delivery::PROFILEUPDATE, 0, $inbox, $uid, $receivers); } diff --git a/src/Worker/PubSubPublish.php b/src/Worker/PubSubPublish.php index f9c311b2d9..4b1c78bf2d 100644 --- a/src/Worker/PubSubPublish.php +++ b/src/Worker/PubSubPublish.php @@ -48,7 +48,7 @@ class PubSubPublish /// @todo Check server status with GServer::check() // Before this can be done we need a way to safely detect the server url. - Logger::log("Generate feed of user " . $subscriber['nickname']. " to " . $subscriber['callback_url']. " - last updated " . $subscriber['last_update'], Logger::DEBUG); + Logger::info("Generate feed of user " . $subscriber['nickname']. " to " . $subscriber['callback_url']. " - last updated " . $subscriber['last_update']); $last_update = $subscriber['last_update']; $params = OStatus::feed($subscriber['nickname'], $last_update); @@ -66,17 +66,17 @@ class PubSubPublish $subscriber['topic']), 'X-Hub-Signature' => 'sha1=' . $hmac_sig]; - Logger::log('POST ' . print_r($headers, true) . "\n" . $params, Logger::DATA); + Logger::debug('POST ' . ['headers' => $headers, 'params' => $params]); $postResult = DI::httpClient()->post($subscriber['callback_url'], $params, $headers); $ret = $postResult->getReturnCode(); if ($ret >= 200 && $ret <= 299) { - Logger::log('Successfully pushed to ' . $subscriber['callback_url']); + Logger::notice('Successfully pushed to ' . $subscriber['callback_url']); PushSubscriber::reset($subscriber['id'], $last_update); } else { - Logger::log('Delivery error when pushing to ' . $subscriber['callback_url'] . ' HTTP: ' . $ret); + Logger::notice('Delivery error when pushing to ' . $subscriber['callback_url'] . ' HTTP: ' . $ret); PushSubscriber::delay($subscriber['id']); } diff --git a/view/theme/frio/theme.php b/view/theme/frio/theme.php index 961eb2a5eb..9315934970 100644 --- a/view/theme/frio/theme.php +++ b/view/theme/frio/theme.php @@ -57,7 +57,7 @@ function frio_install() Hook::register('nav_info', 'view/theme/frio/theme.php', 'frio_remote_nav'); Hook::register('display_item', 'view/theme/frio/theme.php', 'frio_display_item'); - Logger::log('installed theme frio'); + Logger::notice('installed theme frio'); } /** diff --git a/view/theme/vier/style.php b/view/theme/vier/style.php index 6ae61fd955..a1b492b950 100644 --- a/view/theme/vier/style.php +++ b/view/theme/vier/style.php @@ -49,7 +49,7 @@ foreach (['style', $style] as $file) { } } else { //TODO: use Logger::ERROR? - Logger::log('Error: missing file: "' . $stylecssfile .'" (userid: '. $uid .')'); + Logger::notice('Error: missing file: "' . $stylecssfile .'" (userid: '. $uid .')'); } } $modified = gmdate('r', $modified);