Logger Levels

update logger levels in calls
This commit is contained in:
Adam Magness 2018-10-30 09:58:45 -04:00
parent 91ef9f238c
commit 50da89d861
86 changed files with 673 additions and 673 deletions

View file

@ -85,14 +85,14 @@ class PortableContact
$url = $url . (($uid) ? '/@me/@all?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation' : '?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation') ;
Logger::log('load: ' . $url, LOGGER_DEBUG);
Logger::log('load: ' . $url, Logger::DEBUG);
$fetchresult = Network::fetchUrlFull($url);
$s = $fetchresult->getBody();
Logger::log('load: returns ' . $s, LOGGER_DATA);
Logger::log('load: returns ' . $s, Logger::DATA);
Logger::log('load: return code: ' . $fetchresult->getReturnCode(), LOGGER_DEBUG);
Logger::log('load: return code: ' . $fetchresult->getReturnCode(), Logger::DEBUG);
if (($fetchresult->getReturnCode() > 299) || (! $s)) {
return;
@ -100,7 +100,7 @@ class PortableContact
$j = json_decode($s, true);
Logger::log('load: json: ' . print_r($j, true), LOGGER_DATA);
Logger::log('load: json: ' . print_r($j, true), Logger::DATA);
if (!isset($j['entry'])) {
return;
@ -200,10 +200,10 @@ class PortableContact
GContact::link($gcid, $uid, $cid, $zcid);
} catch (Exception $e) {
Logger::log($e->getMessage(), LOGGER_DEBUG);
Logger::log($e->getMessage(), Logger::DEBUG);
}
}
Logger::log("load: loaded $total entries", LOGGER_DEBUG);
Logger::log("load: loaded $total entries", Logger::DEBUG);
$condition = ["`cid` = ? AND `uid` = ? AND `zcid` = ? AND `updated` < UTC_TIMESTAMP - INTERVAL 2 DAY", $cid, $uid, $zcid];
DBA::delete('glink', $condition);
@ -336,7 +336,7 @@ class PortableContact
}
if (!in_array($gcontacts[0]["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::FEED, Protocol::OSTATUS, ""])) {
Logger::log("Profile ".$profile.": Network type ".$gcontacts[0]["network"]." can't be checked", LOGGER_DEBUG);
Logger::log("Profile ".$profile.": Network type ".$gcontacts[0]["network"]." can't be checked", Logger::DEBUG);
return false;
}
@ -347,7 +347,7 @@ class PortableContact
DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
}
Logger::log("Profile ".$profile.": Server ".$server_url." wasn't reachable.", LOGGER_DEBUG);
Logger::log("Profile ".$profile.": Server ".$server_url." wasn't reachable.", Logger::DEBUG);
return false;
}
$contact['server_url'] = $server_url;
@ -427,7 +427,7 @@ class PortableContact
$fields = ['last_contact' => DateTimeFormat::utcNow()];
DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
Logger::log("Profile ".$profile." was last updated at ".$noscrape["updated"]." (noscrape)", LOGGER_DEBUG);
Logger::log("Profile ".$profile." was last updated at ".$noscrape["updated"]." (noscrape)", Logger::DEBUG);
return $noscrape["updated"];
}
@ -438,7 +438,7 @@ class PortableContact
// If we only can poll the feed, then we only do this once a while
if (!$force && !self::updateNeeded($gcontacts[0]["created"], $gcontacts[0]["updated"], $gcontacts[0]["last_failure"], $gcontacts[0]["last_contact"])) {
Logger::log("Profile ".$profile." was last updated at ".$gcontacts[0]["updated"]." (cached)", LOGGER_DEBUG);
Logger::log("Profile ".$profile." was last updated at ".$gcontacts[0]["updated"]." (cached)", Logger::DEBUG);
GContact::update($contact);
return $gcontacts[0]["updated"];
@ -465,10 +465,10 @@ class PortableContact
self::lastUpdated($data["url"], $force);
} catch (Exception $e) {
Logger::log($e->getMessage(), LOGGER_DEBUG);
Logger::log($e->getMessage(), Logger::DEBUG);
}
Logger::log("Profile ".$profile." was deleted", LOGGER_DEBUG);
Logger::log("Profile ".$profile." was deleted", Logger::DEBUG);
return false;
}
@ -476,7 +476,7 @@ class PortableContact
$fields = ['last_failure' => DateTimeFormat::utcNow()];
DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
Logger::log("Profile ".$profile." wasn't reachable (profile)", LOGGER_DEBUG);
Logger::log("Profile ".$profile." wasn't reachable (profile)", Logger::DEBUG);
return false;
}
@ -492,7 +492,7 @@ class PortableContact
$fields = ['last_failure' => DateTimeFormat::utcNow()];
DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
Logger::log("Profile ".$profile." wasn't reachable (no feed)", LOGGER_DEBUG);
Logger::log("Profile ".$profile." wasn't reachable (no feed)", Logger::DEBUG);
return false;
}
@ -540,7 +540,7 @@ class PortableContact
DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
}
Logger::log("Profile ".$profile." was last updated at ".$last_updated, LOGGER_DEBUG);
Logger::log("Profile ".$profile." was last updated at ".$last_updated, Logger::DEBUG);
return $last_updated;
}
@ -663,7 +663,7 @@ class PortableContact
foreach ($nodeinfo['links'] as $link) {
if (!is_array($link) || empty($link['rel'])) {
Logger::log('Invalid nodeinfo format for ' . $server_url, LOGGER_DEBUG);
Logger::log('Invalid nodeinfo format for ' . $server_url, Logger::DEBUG);
continue;
}
if ($link['rel'] == 'http://nodeinfo.diaspora.software/ns/schema/1.0') {
@ -964,7 +964,7 @@ class PortableContact
}
if (!$force && !self::updateNeeded($gserver["created"], "", $last_failure, $last_contact)) {
Logger::log("Use cached data for server ".$server_url, LOGGER_DEBUG);
Logger::log("Use cached data for server ".$server_url, Logger::DEBUG);
return ($last_contact >= $last_failure);
}
} else {
@ -980,7 +980,7 @@ class PortableContact
$last_contact = DBA::NULL_DATETIME;
$last_failure = DBA::NULL_DATETIME;
}
Logger::log("Server ".$server_url." is outdated or unknown. Start discovery. Force: ".$force." Created: ".$gserver["created"]." Failure: ".$last_failure." Contact: ".$last_contact, LOGGER_DEBUG);
Logger::log("Server ".$server_url." is outdated or unknown. Start discovery. Force: ".$force." Created: ".$gserver["created"]." Failure: ".$last_failure." Contact: ".$last_contact, Logger::DEBUG);
$failure = false;
$possible_failure = false;
@ -1005,7 +1005,7 @@ class PortableContact
// But we want to make sure to only quit if we are mostly sure that this server url fits.
if (DBA::isResult($gserver) && ($orig_server_url == $server_url) &&
($curlResult->isTimeout())) {
Logger::log("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
Logger::log("Connection to server ".$server_url." timed out.", Logger::DEBUG);
DBA::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
return false;
}
@ -1020,7 +1020,7 @@ class PortableContact
// Quit if there is a timeout
if ($curlResult->isTimeout()) {
Logger::log("Connection to server " . $server_url . " timed out.", LOGGER_DEBUG);
Logger::log("Connection to server " . $server_url . " timed out.", Logger::DEBUG);
DBA::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
return false;
}
@ -1399,9 +1399,9 @@ class PortableContact
}
if (($last_contact <= $last_failure) && !$failure) {
Logger::log("Server ".$server_url." seems to be alive, but last contact wasn't set - could be a bug", LOGGER_DEBUG);
Logger::log("Server ".$server_url." seems to be alive, but last contact wasn't set - could be a bug", Logger::DEBUG);
} elseif (($last_contact >= $last_failure) && $failure) {
Logger::log("Server ".$server_url." seems to be dead, but last failure wasn't set - could be a bug", LOGGER_DEBUG);
Logger::log("Server ".$server_url." seems to be dead, but last failure wasn't set - could be a bug", Logger::DEBUG);
}
// Check again if the server exists
@ -1430,7 +1430,7 @@ class PortableContact
self::discoverRelay($server_url);
}
Logger::log("End discovery for server " . $server_url, LOGGER_DEBUG);
Logger::log("End discovery for server " . $server_url, Logger::DEBUG);
return !$failure;
}
@ -1442,7 +1442,7 @@ class PortableContact
*/
private static function discoverRelay($server_url)
{
Logger::log("Discover relay data for server " . $server_url, LOGGER_DEBUG);
Logger::log("Discover relay data for server " . $server_url, Logger::DEBUG);
$curlResult = Network::curl($server_url . "/.well-known/x-social-relay");
@ -1558,7 +1558,7 @@ class PortableContact
$r = q("SELECT `nurl` FROM `gserver` WHERE `nurl` = '%s'", DBA::escape(normalise_link($server_url)));
if (!DBA::isResult($r)) {
Logger::log("Call server check for server ".$server_url, LOGGER_DEBUG);
Logger::log("Call server check for server ".$server_url, Logger::DEBUG);
Worker::add(PRIORITY_LOW, "DiscoverPoCo", "server", $server_url);
}
}
@ -1643,7 +1643,7 @@ class PortableContact
// Fetch all users from the other server
$url = $server["poco"] . "/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation";
Logger::log("Fetch all users from the server " . $server["url"], LOGGER_DEBUG);
Logger::log("Fetch all users from the server " . $server["url"], Logger::DEBUG);
$curlResult = Network::curl($url);
@ -1671,7 +1671,7 @@ class PortableContact
$curlResult = Network::curl($url);
if ($curlResult->isSuccess() && !empty($curlResult->getBody())) {
Logger::log("Fetch all global contacts from the server " . $server["nurl"], LOGGER_DEBUG);
Logger::log("Fetch all global contacts from the server " . $server["nurl"], Logger::DEBUG);
$data = json_decode($curlResult->getBody(), true);
if (!empty($data)) {
@ -1680,7 +1680,7 @@ class PortableContact
}
if (!$success && (Config::get('system', 'poco_discovery') > 2)) {
Logger::log("Fetch contacts from users of the server " . $server["nurl"], LOGGER_DEBUG);
Logger::log("Fetch contacts from users of the server " . $server["nurl"], Logger::DEBUG);
self::discoverServerUsers($data, $server);
}
}
@ -1733,7 +1733,7 @@ class PortableContact
continue;
}
Logger::log('Update directory from server ' . $gserver['url'] . ' with ID ' . $gserver['id'], LOGGER_DEBUG);
Logger::log('Update directory from server ' . $gserver['url'] . ' with ID ' . $gserver['id'], Logger::DEBUG);
Worker::add(PRIORITY_LOW, 'DiscoverPoCo', 'update_server_directory', (int) $gserver['id']);
if (!$complete && ( --$no_of_queries == 0)) {
@ -1763,7 +1763,7 @@ class PortableContact
}
if ($username != '') {
Logger::log('Fetch contacts for the user ' . $username . ' from the server ' . $server['nurl'], LOGGER_DEBUG);
Logger::log('Fetch contacts for the user ' . $username . ' from the server ' . $server['nurl'], Logger::DEBUG);
// Fetch all contacts from a given user from the other server
$url = $server['poco'] . '/' . $username . '/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation';
@ -1866,7 +1866,7 @@ class PortableContact
if ($generation > 0) {
$success = true;
Logger::log("Store profile ".$profile_url, LOGGER_DEBUG);
Logger::log("Store profile ".$profile_url, Logger::DEBUG);
$gcontact = ["url" => $profile_url,
"name" => $name,
@ -1885,10 +1885,10 @@ class PortableContact
$gcontact = GContact::sanitize($gcontact);
GContact::update($gcontact);
} catch (Exception $e) {
Logger::log($e->getMessage(), LOGGER_DEBUG);
Logger::log($e->getMessage(), Logger::DEBUG);
}
Logger::log("Done for profile ".$profile_url, LOGGER_DEBUG);
Logger::log("Done for profile ".$profile_url, Logger::DEBUG);
}
}
return $success;