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

@ -159,7 +159,7 @@ class Processor
{
$owner = Contact::getIdForURL($activity['actor']);
Logger::log('Deleting item ' . $activity['object_id'] . ' from ' . $owner, LOGGER_DEBUG);
Logger::log('Deleting item ' . $activity['object_id'] . ' from ' . $owner, Logger::DEBUG);
Item::delete(['uri' => $activity['object_id'], 'owner-id' => $owner]);
}
@ -212,7 +212,7 @@ class Processor
}
$event_id = Event::store($event);
Logger::log('Event '.$event_id.' was stored', LOGGER_DEBUG);
Logger::log('Event '.$event_id.' was stored', Logger::DEBUG);
}
/**
@ -226,7 +226,7 @@ class Processor
/// @todo What to do with $activity['context']?
if (($item['gravity'] != GRAVITY_PARENT) && !Item::exists(['uri' => $item['parent-uri']])) {
Logger::log('Parent ' . $item['parent-uri'] . ' not found, message will be discarded.', LOGGER_DEBUG);
Logger::log('Parent ' . $item['parent-uri'] . ' not found, message will be discarded.', Logger::DEBUG);
return;
}
@ -239,7 +239,7 @@ class Processor
$item['owner-link'] = $activity['actor'];
$item['owner-id'] = Contact::getIdForURL($activity['actor'], 0, true);
} else {
Logger::log('Ignoring actor because of thread completion.', LOGGER_DEBUG);
Logger::log('Ignoring actor because of thread completion.', Logger::DEBUG);
$item['owner-link'] = $item['author-link'];
$item['owner-id'] = $item['author-id'];
}
@ -375,7 +375,7 @@ class Processor
return;
}
Logger::log('Updating profile for ' . $activity['object_id'], LOGGER_DEBUG);
Logger::log('Updating profile for ' . $activity['object_id'], Logger::DEBUG);
APContact::getByURL($activity['object_id'], true);
}
@ -387,12 +387,12 @@ class Processor
public static function deletePerson($activity)
{
if (empty($activity['object_id']) || empty($activity['actor'])) {
Logger::log('Empty object id or actor.', LOGGER_DEBUG);
Logger::log('Empty object id or actor.', Logger::DEBUG);
return;
}
if ($activity['object_id'] != $activity['actor']) {
Logger::log('Object id does not match actor.', LOGGER_DEBUG);
Logger::log('Object id does not match actor.', Logger::DEBUG);
return;
}
@ -402,7 +402,7 @@ class Processor
}
DBA::close($contacts);
Logger::log('Deleted contact ' . $activity['object_id'], LOGGER_DEBUG);
Logger::log('Deleted contact ' . $activity['object_id'], Logger::DEBUG);
}
/**
@ -421,7 +421,7 @@ class Processor
$cid = Contact::getIdForURL($activity['actor'], $uid);
if (empty($cid)) {
Logger::log('No contact found for ' . $activity['actor'], LOGGER_DEBUG);
Logger::log('No contact found for ' . $activity['actor'], Logger::DEBUG);
return;
}
@ -436,7 +436,7 @@ class Processor
$condition = ['id' => $cid];
DBA::update('contact', $fields, $condition);
Logger::log('Accept contact request from contact ' . $cid . ' for user ' . $uid, LOGGER_DEBUG);
Logger::log('Accept contact request from contact ' . $cid . ' for user ' . $uid, Logger::DEBUG);
}
/**
@ -455,7 +455,7 @@ class Processor
$cid = Contact::getIdForURL($activity['actor'], $uid);
if (empty($cid)) {
Logger::log('No contact found for ' . $activity['actor'], LOGGER_DEBUG);
Logger::log('No contact found for ' . $activity['actor'], Logger::DEBUG);
return;
}
@ -463,9 +463,9 @@ class Processor
if (DBA::exists('contact', ['id' => $cid, 'rel' => Contact::SHARING, 'pending' => true])) {
Contact::remove($cid);
Logger::log('Rejected contact request from contact ' . $cid . ' for user ' . $uid . ' - contact had been removed.', LOGGER_DEBUG);
Logger::log('Rejected contact request from contact ' . $cid . ' for user ' . $uid . ' - contact had been removed.', Logger::DEBUG);
} else {
Logger::log('Rejected contact request from contact ' . $cid . ' for user ' . $uid . '.', LOGGER_DEBUG);
Logger::log('Rejected contact request from contact ' . $cid . ' for user ' . $uid . '.', Logger::DEBUG);
}
}
@ -508,7 +508,7 @@ class Processor
$cid = Contact::getIdForURL($activity['actor'], $uid);
if (empty($cid)) {
Logger::log('No contact found for ' . $activity['actor'], LOGGER_DEBUG);
Logger::log('No contact found for ' . $activity['actor'], Logger::DEBUG);
return;
}
@ -520,7 +520,7 @@ class Processor
}
Contact::removeFollower($owner, $contact);
Logger::log('Undo following request from contact ' . $cid . ' for user ' . $uid, LOGGER_DEBUG);
Logger::log('Undo following request from contact ' . $cid . ' for user ' . $uid, Logger::DEBUG);
}
/**

View file

@ -60,16 +60,16 @@ class Receiver
{
$http_signer = HTTPSignature::getSigner($body, $header);
if (empty($http_signer)) {
Logger::log('Invalid HTTP signature, message will be discarded.', LOGGER_DEBUG);
Logger::log('Invalid HTTP signature, message will be discarded.', Logger::DEBUG);
return;
} else {
Logger::log('HTTP signature is signed by ' . $http_signer, LOGGER_DEBUG);
Logger::log('HTTP signature is signed by ' . $http_signer, Logger::DEBUG);
}
$activity = json_decode($body, true);
if (empty($activity)) {
Logger::log('Invalid body.', LOGGER_DEBUG);
Logger::log('Invalid body.', Logger::DEBUG);
return;
}
@ -77,31 +77,31 @@ class Receiver
$actor = JsonLD::fetchElement($ldactivity, 'as:actor');
Logger::log('Message for user ' . $uid . ' is from actor ' . $actor, LOGGER_DEBUG);
Logger::log('Message for user ' . $uid . ' is from actor ' . $actor, Logger::DEBUG);
if (LDSignature::isSigned($activity)) {
$ld_signer = LDSignature::getSigner($activity);
if (empty($ld_signer)) {
Logger::log('Invalid JSON-LD signature from ' . $actor, LOGGER_DEBUG);
Logger::log('Invalid JSON-LD signature from ' . $actor, Logger::DEBUG);
}
if (!empty($ld_signer && ($actor == $http_signer))) {
Logger::log('The HTTP and the JSON-LD signature belong to ' . $ld_signer, LOGGER_DEBUG);
Logger::log('The HTTP and the JSON-LD signature belong to ' . $ld_signer, Logger::DEBUG);
$trust_source = true;
} elseif (!empty($ld_signer)) {
Logger::log('JSON-LD signature is signed by ' . $ld_signer, LOGGER_DEBUG);
Logger::log('JSON-LD signature is signed by ' . $ld_signer, Logger::DEBUG);
$trust_source = true;
} elseif ($actor == $http_signer) {
Logger::log('Bad JSON-LD signature, but HTTP signer fits the actor.', LOGGER_DEBUG);
Logger::log('Bad JSON-LD signature, but HTTP signer fits the actor.', Logger::DEBUG);
$trust_source = true;
} else {
Logger::log('Invalid JSON-LD signature and the HTTP signer is different.', LOGGER_DEBUG);
Logger::log('Invalid JSON-LD signature and the HTTP signer is different.', Logger::DEBUG);
$trust_source = false;
}
} elseif ($actor == $http_signer) {
Logger::log('Trusting post without JSON-LD signature, The actor fits the HTTP signer.', LOGGER_DEBUG);
Logger::log('Trusting post without JSON-LD signature, The actor fits the HTTP signer.', Logger::DEBUG);
$trust_source = true;
} else {
Logger::log('No JSON-LD signature, different actor.', LOGGER_DEBUG);
Logger::log('No JSON-LD signature, different actor.', Logger::DEBUG);
$trust_source = false;
}
@ -160,7 +160,7 @@ class Receiver
{
$actor = JsonLD::fetchElement($activity, 'as:actor');
if (empty($actor)) {
Logger::log('Empty actor', LOGGER_DEBUG);
Logger::log('Empty actor', Logger::DEBUG);
return [];
}
@ -176,11 +176,11 @@ class Receiver
$receivers = array_merge($receivers, $additional);
}
Logger::log('Receivers: ' . json_encode($receivers), LOGGER_DEBUG);
Logger::log('Receivers: ' . json_encode($receivers), Logger::DEBUG);
$object_id = JsonLD::fetchElement($activity, 'as:object');
if (empty($object_id)) {
Logger::log('No object found', LOGGER_DEBUG);
Logger::log('No object found', Logger::DEBUG);
return [];
}
@ -193,7 +193,7 @@ class Receiver
}
$object_data = self::fetchObject($object_id, $activity['as:object'], $trust_source);
if (empty($object_data)) {
Logger::log("Object data couldn't be processed", LOGGER_DEBUG);
Logger::log("Object data couldn't be processed", Logger::DEBUG);
return [];
}
// We had been able to retrieve the object data - so we can trust the source
@ -230,7 +230,7 @@ class Receiver
$object_data['actor'] = $actor;
$object_data['receiver'] = array_merge(defaults($object_data, 'receiver', []), $receivers);
Logger::log('Processing ' . $object_data['type'] . ' ' . $object_data['object_type'] . ' ' . $object_data['id'], LOGGER_DEBUG);
Logger::log('Processing ' . $object_data['type'] . ' ' . $object_data['object_type'] . ' ' . $object_data['id'], Logger::DEBUG);
return $object_data;
}
@ -273,17 +273,17 @@ class Receiver
{
$type = JsonLD::fetchElement($activity, '@type');
if (!$type) {
Logger::log('Empty type', LOGGER_DEBUG);
Logger::log('Empty type', Logger::DEBUG);
return;
}
if (!JsonLD::fetchElement($activity, 'as:object')) {
Logger::log('Empty object', LOGGER_DEBUG);
Logger::log('Empty object', Logger::DEBUG);
return;
}
if (!JsonLD::fetchElement($activity, 'as:actor')) {
Logger::log('Empty actor', LOGGER_DEBUG);
Logger::log('Empty actor', Logger::DEBUG);
return;
}
@ -291,12 +291,12 @@ class Receiver
// $trust_source is called by reference and is set to true if the content was retrieved successfully
$object_data = self::prepareObjectData($activity, $uid, $trust_source);
if (empty($object_data)) {
Logger::log('No object data found', LOGGER_DEBUG);
Logger::log('No object data found', Logger::DEBUG);
return;
}
if (!$trust_source) {
Logger::log('No trust for activity type "' . $type . '", so we quit now.', LOGGER_DEBUG);
Logger::log('No trust for activity type "' . $type . '", so we quit now.', Logger::DEBUG);
return;
}
@ -385,7 +385,7 @@ class Receiver
break;
default:
Logger::log('Unknown activity: ' . $type . ' ' . $object_data['object_type'], LOGGER_DEBUG);
Logger::log('Unknown activity: ' . $type . ' ' . $object_data['object_type'], Logger::DEBUG);
break;
}
}
@ -415,9 +415,9 @@ class Receiver
$profile = APContact::getByURL($actor);
$followers = defaults($profile, 'followers', '');
Logger::log('Actor: ' . $actor . ' - Followers: ' . $followers, LOGGER_DEBUG);
Logger::log('Actor: ' . $actor . ' - Followers: ' . $followers, Logger::DEBUG);
} else {
Logger::log('Empty actor', LOGGER_DEBUG);
Logger::log('Empty actor', Logger::DEBUG);
$followers = '';
}
@ -501,7 +501,7 @@ class Receiver
// Send a new follow request to be sure that the connection still exists
if (($uid != 0) && DBA::exists('contact', ['id' => $cid, 'rel' => [Contact::SHARING, Contact::FRIEND]])) {
ActivityPub\Transmitter::sendActivity('Follow', $profile['url'], $uid);
Logger::log('Send a new follow request to ' . $profile['url'] . ' for user ' . $uid, LOGGER_DEBUG);
Logger::log('Send a new follow request to ' . $profile['url'] . ' for user ' . $uid, Logger::DEBUG);
}
}
@ -571,27 +571,27 @@ class Receiver
$data = ActivityPub::fetchContent($object_id);
if (!empty($data)) {
$object = JsonLD::compact($data);
Logger::log('Fetched content for ' . $object_id, LOGGER_DEBUG);
Logger::log('Fetched content for ' . $object_id, Logger::DEBUG);
} else {
Logger::log('Empty content for ' . $object_id . ', check if content is available locally.', LOGGER_DEBUG);
Logger::log('Empty content for ' . $object_id . ', check if content is available locally.', Logger::DEBUG);
$item = Item::selectFirst([], ['uri' => $object_id]);
if (!DBA::isResult($item)) {
Logger::log('Object with url ' . $object_id . ' was not found locally.', LOGGER_DEBUG);
Logger::log('Object with url ' . $object_id . ' was not found locally.', Logger::DEBUG);
return false;
}
Logger::log('Using already stored item for url ' . $object_id, LOGGER_DEBUG);
Logger::log('Using already stored item for url ' . $object_id, Logger::DEBUG);
$data = ActivityPub\Transmitter::createNote($item);
$object = JsonLD::compact($data);
}
} else {
Logger::log('Using original object for url ' . $object_id, LOGGER_DEBUG);
Logger::log('Using original object for url ' . $object_id, Logger::DEBUG);
}
$type = JsonLD::fetchElement($object, '@type');
if (empty($type)) {
Logger::log('Empty type', LOGGER_DEBUG);
Logger::log('Empty type', Logger::DEBUG);
return false;
}
@ -607,7 +607,7 @@ class Receiver
return self::fetchObject($object_id);
}
Logger::log('Unhandled object type: ' . $type, LOGGER_DEBUG);
Logger::log('Unhandled object type: ' . $type, Logger::DEBUG);
}
/**

View file

@ -1016,7 +1016,7 @@ class Transmitter
$signed = LDSignature::sign($data, $owner);
Logger::log('Deliver profile deletion for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', LOGGER_DEBUG);
Logger::log('Deliver profile deletion for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', Logger::DEBUG);
return HTTPSignature::transmit($signed, $inbox, $uid);
}
@ -1045,7 +1045,7 @@ class Transmitter
$signed = LDSignature::sign($data, $owner);
Logger::log('Deliver profile deletion for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', LOGGER_DEBUG);
Logger::log('Deliver profile deletion for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', Logger::DEBUG);
return HTTPSignature::transmit($signed, $inbox, $uid);
}
@ -1074,7 +1074,7 @@ class Transmitter
$signed = LDSignature::sign($data, $owner);
Logger::log('Deliver profile update for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', LOGGER_DEBUG);
Logger::log('Deliver profile update for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', Logger::DEBUG);
return HTTPSignature::transmit($signed, $inbox, $uid);
}
@ -1099,7 +1099,7 @@ class Transmitter
'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
'to' => $profile['url']];
Logger::log('Sending activity ' . $activity . ' to ' . $target . ' for user ' . $uid, LOGGER_DEBUG);
Logger::log('Sending activity ' . $activity . ' to ' . $target . ' for user ' . $uid, Logger::DEBUG);
$signed = LDSignature::sign($data, $owner);
HTTPSignature::transmit($signed, $profile['inbox'], $uid);
@ -1127,7 +1127,7 @@ class Transmitter
'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
'to' => $profile['url']];
Logger::log('Sending accept to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG);
Logger::log('Sending accept to ' . $target . ' for user ' . $uid . ' with id ' . $id, Logger::DEBUG);
$signed = LDSignature::sign($data, $owner);
HTTPSignature::transmit($signed, $profile['inbox'], $uid);
@ -1155,7 +1155,7 @@ class Transmitter
'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
'to' => $profile['url']];
Logger::log('Sending reject to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG);
Logger::log('Sending reject to ' . $target . ' for user ' . $uid . ' with id ' . $id, Logger::DEBUG);
$signed = LDSignature::sign($data, $owner);
HTTPSignature::transmit($signed, $profile['inbox'], $uid);
@ -1184,7 +1184,7 @@ class Transmitter
'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()],
'to' => $profile['url']];
Logger::log('Sending undo to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG);
Logger::log('Sending undo to ' . $target . ' for user ' . $uid . ' with id ' . $id, Logger::DEBUG);
$signed = LDSignature::sign($data, $owner);
HTTPSignature::transmit($signed, $profile['inbox'], $uid);