$a = \get_app();
// Temporary logging for finding the origin
- if (!isset($params['language']) || !isset($params['uid'])) {
- Logger::log('Missing parameters.' . System::callstack());
+ if (!isset($params['uid'])) {
+ Logger::notice('Missing parameters "uid".', ['params' => $params, 'callstack' => System::callstack()]);
}
// Ensure that the important fields are set at any time
$user = DBA::selectFirst('user', $fields, ['uid' => $params['uid']]);
if (!DBA::isResult($user)) {
- Logger::log('Unknown user ' . $params['uid']);
+ Logger::error('Unknown user', ['uid' => $params['uid']]);
return false;
}
}
if ($parent) {
- Logger::log('mod_item: item_post parent=' . $parent);
+ Logger::info('mod_item: item_post parent=' . $toplevel_item_id);
}
$post_id = intval(defaults($_REQUEST, 'post_id', 0));
if ((substr_count($sql, '?') != count($args)) && (count($args) > 0)) {
// Question: Should we continue or stop the query here?
- Logger::log('Parameter mismatch. Query "'.$sql.'" - Parameters '.print_r($args, true), Logger::DEBUG);
+ Logger::error('Parameter mismatch. Query "'.$sql.'" - Parameters '.print_r($args, true));
}
$sql = self::cleanQuery($sql);
$expire_date = time() - ($expire_interval * 86400);
$created_date = strtotime($item['created']);
if ($created_date < $expire_date) {
- Logger::log('item-store: item created ('.date('c', $created_date).') before expiration time ('.date('c', $expire_date).'). ignored. ' . print_r($item,true), Logger::DEBUG);
+ Logger::notice('item-store: item created ('.date('c', $created_date).') before expiration time ('.date('c', $expire_date).'). ignored. ' . print_r($item,true));
return 0;
}
}
if (DBA::isResult($existing)) {
// We only log the entries with a different user id than 0. Otherwise we would have too many false positives
if ($uid != 0) {
- Logger::log("Item with uri ".$item['uri']." already existed for user ".$uid." with id ".$existing["id"]." target network ".$existing["network"]." - new network: ".$item['network']);
+ Logger::notice("Item with uri ".$item['uri']." already existed for user ".$uid." with id ".$existing["id"]." target network ".$existing["network"]." - new network: ".$item['network']);
}
return $existing["id"];
// When there is no content then we don't post it
if ($item['body'].$item['title'] == '') {
- Logger::log('No body, no title.');
+ Logger::notice('No body, no title.');
return 0;
}
$item['author-id'] = defaults($item, 'author-id', Contact::getIdForURL($item["author-link"], 0, false, $default));
if (Contact::isBlocked($item["author-id"])) {
- Logger::log('Contact '.$item["author-id"].' is blocked, item '.$item["uri"].' will not be stored');
+ Logger::notice('Contact '.$item["author-id"].' is blocked, item '.$item["uri"].' will not be stored');
return 0;
}
$item['owner-id'] = defaults($item, 'owner-id', Contact::getIdForURL($item["owner-link"], 0, false, $default));
if (Contact::isBlocked($item["owner-id"])) {
- Logger::log('Contact '.$item["owner-id"].' is blocked, item '.$item["uri"].' will not be stored');
+ Logger::notice('Contact '.$item["owner-id"].' is blocked, item '.$item["uri"].' will not be stored');
return 0;
}
if ($item['network'] == Protocol::PHANTOM) {
- Logger::log('Missing network. Called by: '.System::callstack(), Logger::DEBUG);
+ Logger::notice('Missing network. Called by: '.System::callstack(), Logger::DEBUG);
$item['network'] = Protocol::DFRN;
- Logger::log("Set network to " . $item["network"] . " for " . $item["uri"], Logger::DEBUG);
+ Logger::notice("Set network to " . $item["network"] . " for " . $item["uri"], Logger::DEBUG);
}
// Checking if there is already an item with the same guid
- Logger::log('Checking for an item for user '.$item['uid'].' on network '.$item['network'].' with the guid '.$item['guid'], Logger::DEBUG);
$condition = ['guid' => $item['guid'], 'network' => $item['network'], 'uid' => $item['uid']];
if (self::exists($condition)) {
- Logger::log('found item with guid '.$item['guid'].' for user '.$item['uid'].' on network '.$item['network'], Logger::DEBUG);
+ Logger::notice('Found already existing item with guid '.$item['guid'].' for user '.$item['uid'].' on network '.$item['network']);
return 0;
}
$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::info('Ignoring actor because of thread completion.');
$item['owner-link'] = $item['author-link'];
$item['owner-id'] = $item['author-id'];
}
}
$item_id = Item::insert($item);
- Logger::log('Storing for user ' . $item['uid'] . ': ' . $item_id);
+ if ($item_id) {
+ Logger::info('Item insertion successful', ['user' => $item['uid'], 'item_id' => $item_id]);
+ } else {
+ Logger::notice('Item insertion aborted', ['user' => $item['uid']]);
+ }
if ($item['uid'] == 0) {
$stored = $item_id;
{
$http_signer = HTTPSignature::getSigner($body, $header);
if (empty($http_signer)) {
- Logger::log('Invalid HTTP signature, message will be discarded.', Logger::DEBUG);
+ Logger::warning('Invalid HTTP signature, message will be discarded.');
return;
} else {
- Logger::log('HTTP signature is signed by ' . $http_signer, Logger::DEBUG);
+ Logger::info('Valid HTTP signature', ['signer' => $http_signer]);
}
$activity = json_decode($body, true);
if (empty($activity)) {
- Logger::log('Invalid body.', Logger::DEBUG);
+ Logger::warning('Invalid body.');
return;
}
$actor = JsonLD::fetchElement($ldactivity, 'as:actor');
- Logger::log('Message for user ' . $uid . ' is from actor ' . $actor, Logger::DEBUG);
+ Logger::info('Message for user ' . $uid . ' is from actor ' . $actor);
if (LDSignature::isSigned($activity)) {
$ld_signer = LDSignature::getSigner($activity);
$author["network"] = $contact_old["network"];
} else {
if (!$onlyfetch) {
- Logger::log("Contact ".$author["link"]." wasn't found for user ".$importer["importer_uid"]." XML: ".$xml, Logger::DEBUG);
+ Logger::debug("Contact ".$author["link"]." wasn't found for user ".$importer["importer_uid"]." XML: ".$xml);
}
$author["contact-unknown"] = true;
$person = DBA::selectFirst('fcontact', [], ['network' => Protocol::DIASPORA, 'addr' => $handle]);
if (DBA::isResult($person)) {
- Logger::log("In cache " . print_r($person, true), Logger::DEBUG);
+ Logger::debug("In cache " . print_r($person, true));
// update record occasionally so it doesn't get stale
$d = strtotime($person["updated"]." +00:00");
use Friendica\Core\Logger;
use DOMXPath;
+use Friendica\Core\System;
use SimpleXMLElement;
/**
$x = @simplexml_load_string($s);
if (!$x) {
- Logger::log('libxml: parse: error: ' . $s, Logger::DATA);
+ Logger::error('Error(s) while parsing XML string.', ['callstack' => System::callstack()]);
foreach (libxml_get_errors() as $err) {
- Logger::log('libxml: parse: ' . $err->code." at ".$err->line.":".$err->column." : ".$err->message, Logger::DATA);
+ Logger::info('libxml error', ['code' => $err->code, 'position' => $err->line . ":" . $err->column, 'message' => $err->message]);
}
+ Logger::debug('Erroring XML string', ['xml' => $s]);
libxml_clear_errors();
}
return $x;