Log function

implement log() function.
This commit is contained in:
Adam Magness 2018-10-29 17:20:46 -04:00
parent d6d593d724
commit 14fde5dc9b
122 changed files with 1280 additions and 1161 deletions

View file

@ -6,6 +6,7 @@ namespace Friendica\Util;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\Logger;
use ASN_BASE;
use ASNValue;
@ -232,7 +233,7 @@ class Crypto
$result = openssl_pkey_new($openssl_options);
if (empty($result)) {
logger('new_keypair: failed');
Logger::log('new_keypair: failed');
return false;
}
@ -347,7 +348,7 @@ class Crypto
private static function encapsulateOther($data, $pubkey, $alg)
{
if (!$pubkey) {
logger('no key. data: '.$data);
Logger::log('no key. data: '.$data);
}
$fn = 'encrypt' . strtoupper($alg);
if (method_exists(__CLASS__, $fn)) {
@ -359,7 +360,7 @@ class Crypto
// log the offending call so we can track it down
if (!openssl_public_encrypt($key, $k, $pubkey)) {
$x = debug_backtrace();
logger('RSA failed. ' . print_r($x[0], true));
Logger::log('RSA failed. ' . print_r($x[0], true));
}
$result['alg'] = $alg;
@ -388,7 +389,7 @@ class Crypto
private static function encapsulateAes($data, $pubkey)
{
if (!$pubkey) {
logger('aes_encapsulate: no key. data: ' . $data);
Logger::log('aes_encapsulate: no key. data: ' . $data);
}
$key = random_bytes(32);
@ -399,7 +400,7 @@ class Crypto
// log the offending call so we can track it down
if (!openssl_public_encrypt($key, $k, $pubkey)) {
$x = debug_backtrace();
logger('aes_encapsulate: RSA failed. ' . print_r($x[0], true));
Logger::log('aes_encapsulate: RSA failed. ' . print_r($x[0], true));
}
$result['alg'] = 'aes256cbc';

View file

@ -6,6 +6,7 @@
namespace Friendica\Util;
use Friendica\Core\Logger;
use DateTime;
use DateTimeZone;
use Exception;
@ -125,7 +126,7 @@ class DateTimeFormat
try {
$d = new DateTime($s, $from_obj);
} catch (Exception $e) {
logger('DateTimeFormat::convert: exception: ' . $e->getMessage());
Logger::log('DateTimeFormat::convert: exception: ' . $e->getMessage());
$d = new DateTime('now', $from_obj);
}

View file

@ -6,6 +6,7 @@ namespace Friendica\Util;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\Logger;
use Friendica\Core\PConfig;
use Friendica\Protocol\Email;
@ -96,8 +97,8 @@ class Emailer
$hookdata['headers'],
$hookdata['parameters']
);
logger("header " . 'To: ' . $params['toEmail'] . "\n" . $messageHeader, LOGGER_DEBUG);
logger("return value " . (($res)?"true":"false"), LOGGER_DEBUG);
Logger::log("header " . 'To: ' . $params['toEmail'] . "\n" . $messageHeader, LOGGER_DEBUG);
Logger::log("return value " . (($res)?"true":"false"), LOGGER_DEBUG);
return $res;
}
}

View file

@ -7,6 +7,7 @@ namespace Friendica\Util;
use Friendica\BaseObject;
use Friendica\Core\Config;
use Friendica\Core\Logger;
use Friendica\Database\DBA;
use Friendica\Model\User;
use Friendica\Model\APContact;
@ -59,7 +60,7 @@ class HTTPSignature
$sig_block = self::parseSigheader($headers['authorization']);
if (!$sig_block) {
logger('no signature provided.');
Logger::log('no signature provided.');
return $result;
}
@ -89,7 +90,7 @@ class HTTPSignature
$key = $key($sig_block['keyId']);
}
logger('Got keyID ' . $sig_block['keyId']);
Logger::log('Got keyID ' . $sig_block['keyId']);
if (!$key) {
return $result;
@ -97,7 +98,7 @@ class HTTPSignature
$x = Crypto::rsaVerify($signed_data, $sig_block['signature'], $key, $algorithm);
logger('verified: ' . $x, LOGGER_DEBUG);
Logger::log('verified: ' . $x, LOGGER_DEBUG);
if (!$x) {
return $result;
@ -307,7 +308,7 @@ class HTTPSignature
$postResult = Network::post($target, $content, $headers);
$return_code = $postResult->getReturnCode();
logger('Transmit to ' . $target . ' returned ' . $return_code);
Logger::log('Transmit to ' . $target . ' returned ' . $return_code);
return ($return_code >= 200) && ($return_code <= 299);
}
@ -432,12 +433,12 @@ class HTTPSignature
$profile = APContact::getByURL($url);
if (!empty($profile)) {
logger('Taking key from id ' . $id, LOGGER_DEBUG);
Logger::log('Taking key from id ' . $id, LOGGER_DEBUG);
return ['url' => $url, 'pubkey' => $profile['pubkey']];
} elseif ($url != $actor) {
$profile = APContact::getByURL($actor);
if (!empty($profile)) {
logger('Taking key from actor ' . $actor, LOGGER_DEBUG);
Logger::log('Taking key from actor ' . $actor, LOGGER_DEBUG);
return ['url' => $actor, 'pubkey' => $profile['pubkey']];
}
}

View file

@ -5,6 +5,7 @@
namespace Friendica\Util;
use Friendica\Core\Cache;
use Friendica\Core\Logger;
use Exception;
/**
@ -33,7 +34,7 @@ class JsonLD
}
if ($recursion > 5) {
logger('jsonld bomb detected at: ' . $url);
Logger::log('jsonld bomb detected at: ' . $url);
exit();
}
@ -65,7 +66,7 @@ class JsonLD
}
catch (Exception $e) {
$normalized = false;
logger('normalise error:' . print_r($e, true), LOGGER_DEBUG);
Logger::log('normalise error:' . print_r($e, true), LOGGER_DEBUG);
}
return $normalized;
@ -98,7 +99,7 @@ class JsonLD
}
catch (Exception $e) {
$compacted = false;
logger('compacting error:' . print_r($e, true), LOGGER_DEBUG);
Logger::log('compacting error:' . print_r($e, true), LOGGER_DEBUG);
}
return json_decode(json_encode($compacted, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), true);

View file

@ -2,6 +2,7 @@
namespace Friendica\Util;
use Friendica\Core\Logger;
use Friendica\Util\JsonLD;
use Friendica\Util\DateTimeFormat;
use Friendica\Protocol\ActivityPub;
@ -40,7 +41,7 @@ class LDSignature
$dhash = self::hash(self::signableData($data));
$x = Crypto::rsaVerify($ohash . $dhash, base64_decode($data['signature']['signatureValue']), $pubkey);
logger('LD-verify: ' . intval($x));
Logger::log('LD-verify: ' . intval($x));
if (empty($x)) {
return false;

View file

@ -5,6 +5,7 @@
namespace Friendica\Util;
use Friendica\Core\Addon;
use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Network\CurlResult;
@ -106,7 +107,7 @@ class Network
$url = self::unparseURL($parts);
if (self::isUrlBlocked($url)) {
logger('domain of ' . $url . ' is blocked', LOGGER_DATA);
Logger::log('domain of ' . $url . ' is blocked', LOGGER_DATA);
return CurlResult::createErrorCurl($url);
}
@ -212,7 +213,7 @@ class Network
if ($curlResponse->isRedirectUrl()) {
$redirects++;
logger('curl: redirect ' . $url . ' to ' . $curlResponse->getRedirectUrl());
Logger::log('curl: redirect ' . $url . ' to ' . $curlResponse->getRedirectUrl());
@curl_close($ch);
return self::curl($curlResponse->getRedirectUrl(), $binary, $redirects, $opts);
}
@ -240,7 +241,7 @@ class Network
$stamp1 = microtime(true);
if (self::isUrlBlocked($url)) {
logger('post_url: domain of ' . $url . ' is blocked', LOGGER_DATA);
Logger::log('post_url: domain of ' . $url . ' is blocked', LOGGER_DATA);
return CurlResult::createErrorCurl($url);
}
@ -251,7 +252,7 @@ class Network
return CurlResult::createErrorCurl($url);
}
logger('post_url: start ' . $url, LOGGER_DATA);
Logger::log('post_url: start ' . $url, LOGGER_DATA);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@ -314,7 +315,7 @@ class Network
if ($curlResponse->isRedirectUrl()) {
$redirects++;
logger('post_url: redirect ' . $url . ' to ' . $curlResponse->getRedirectUrl());
Logger::log('post_url: redirect ' . $url . ' to ' . $curlResponse->getRedirectUrl());
curl_close($ch);
return self::post($curlResponse->getRedirectUrl(), $params, $headers, $redirects, $timeout);
}
@ -323,7 +324,7 @@ class Network
$a->saveTimestamp($stamp1, 'network');
logger('post_url: end ' . $url, LOGGER_DATA);
Logger::log('post_url: end ' . $url, LOGGER_DATA);
return $curlResponse;
}
@ -527,7 +528,7 @@ class Network
$avatar['url'] = System::baseUrl() . '/images/person-300.jpg';
}
logger('Avatar: ' . $avatar['email'] . ' ' . $avatar['url'], LOGGER_DEBUG);
Logger::log('Avatar: ' . $avatar['email'] . ' ' . $avatar['url'], LOGGER_DEBUG);
return $avatar['url'];
}

View file

@ -9,6 +9,7 @@ use DOMDocument;
use DOMXPath;
use Friendica\Content\OEmbed;
use Friendica\Core\Addon;
use Friendica\Core\Logger;
use Friendica\Database\DBA;
use Friendica\Object\Image;
@ -123,7 +124,7 @@ class ParseUrl
}
if ($count > 10) {
logger('Endless loop detected for ' . $url, LOGGER_DEBUG);
Logger::log('Endless loop detected for ' . $url, LOGGER_DEBUG);
return $siteinfo;
}
@ -187,7 +188,7 @@ class ParseUrl
}
if (($charset != '') && (strtoupper($charset) != 'UTF-8')) {
logger('detected charset ' . $charset, LOGGER_DEBUG);
Logger::log('detected charset ' . $charset, LOGGER_DEBUG);
$body = iconv($charset, 'UTF-8//TRANSLIT', $body);
}
@ -421,7 +422,7 @@ class ParseUrl
}
}
logger('Siteinfo for ' . $url . ' ' . print_r($siteinfo, true), LOGGER_DEBUG);
Logger::log('Siteinfo for ' . $url . ' ' . print_r($siteinfo, true), LOGGER_DEBUG);
Addon::callHooks('getsiteinfo', $siteinfo);

View file

@ -4,6 +4,7 @@
*/
namespace Friendica\Util;
use Friendica\Core\Logger;
use DOMXPath;
use SimpleXMLElement;
@ -248,7 +249,7 @@ class XML
}
if (!function_exists('xml_parser_create')) {
logger('Xml::toArray: parser function missing');
Logger::log('Xml::toArray: parser function missing');
return [];
}
@ -263,7 +264,7 @@ class XML
}
if (! $parser) {
logger('Xml::toArray: xml_parser_create: no resource');
Logger::log('Xml::toArray: xml_parser_create: no resource');
return [];
}
@ -275,9 +276,9 @@ class XML
@xml_parser_free($parser);
if (! $xml_values) {
logger('Xml::toArray: libxml: parse error: ' . $contents, LOGGER_DATA);
Logger::log('Xml::toArray: libxml: parse error: ' . $contents, LOGGER_DATA);
foreach (libxml_get_errors() as $err) {
logger('libxml: parse: ' . $err->code . " at " . $err->line . ":" . $err->column . " : " . $err->message, LOGGER_DATA);
Logger::log('libxml: parse: ' . $err->code . " at " . $err->line . ":" . $err->column . " : " . $err->message, LOGGER_DATA);
}
libxml_clear_errors();
return;
@ -423,9 +424,9 @@ class XML
$x = @simplexml_load_string($s);
if (!$x) {
logger('libxml: parse: error: ' . $s, LOGGER_DATA);
Logger::log('libxml: parse: error: ' . $s, LOGGER_DATA);
foreach (libxml_get_errors() as $err) {
logger('libxml: parse: ' . $err->code." at ".$err->line.":".$err->column." : ".$err->message, LOGGER_DATA);
Logger::log('libxml: parse: ' . $err->code." at ".$err->line.":".$err->column." : ".$err->message, LOGGER_DATA);
}
libxml_clear_errors();
}