From 49eff56e5d1969a10bcc37c4aa0d8ae74c9f939d Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Mon, 29 Oct 2018 19:40:18 -0400 Subject: [PATCH] Core Logger implement log() function. more to squash Core Logger Class implement log() function --- .../advancedcontentfilter.php | 3 +- blackout/blackout.php | 3 +- blogger/blogger.php | 5 +- buffer/buffer.php | 11 +- catavatar/catavatar.php | 5 +- diaspora/diaspora.php | 39 ++--- dwpost/dwpost.php | 5 +- fromapp/fromapp.php | 5 +- fromgplus/fromgplus.php | 17 +- geocoordinates/geocoordinates.php | 9 +- geonames/geonames.php | 9 +- gnot/gnot.php | 5 +- googlemaps/googlemaps.php | 5 +- gravatar/gravatar.php | 5 +- group_text/group_text.php | 5 +- ifttt/ifttt.php | 11 +- ijpost/ijpost.php | 5 +- impressum/impressum.php | 5 +- jappixmini/jappixmini.php | 3 +- js_upload/js_upload.php | 5 +- krynn/krynn.php | 7 +- ldapauth/ldapauth.php | 21 +-- leistungsschutzrecht/leistungsschutzrecht.php | 3 +- libertree/libertree.php | 5 +- libravatar/libravatar.php | 5 +- ljpost/ljpost.php | 5 +- mailstream/mailstream.php | 25 +-- newmemberwidget/newmemberwidget.php | 3 +- notifyall/notifyall.php | 5 +- numfriends/numfriends.php | 5 +- openstreetmap/openstreetmap.php | 11 +- piwik/piwik.php | 5 +- planets/planets.php | 7 +- public_server/public_server.php | 5 +- pumpio/pumpio.php | 87 +++++------ pumpio/pumpio_sync.php | 3 +- randplace/randplace.php | 7 +- securemail/securemail.php | 5 +- smileybutton/smileybutton.php | 5 +- statusnet/statusnet.php | 83 +++++----- tumblr/tumblr.php | 7 +- twitter/twitter.php | 145 +++++++++--------- twitter/twitter_sync.php | 3 +- widgets/widgets.php | 3 +- windowsphonepush/windowsphonepush.php | 25 +-- wppost/wppost.php | 5 +- 46 files changed, 348 insertions(+), 302 deletions(-) diff --git a/advancedcontentfilter/advancedcontentfilter.php b/advancedcontentfilter/advancedcontentfilter.php index 3f0364886..549698d3f 100644 --- a/advancedcontentfilter/advancedcontentfilter.php +++ b/advancedcontentfilter/advancedcontentfilter.php @@ -39,6 +39,7 @@ use Friendica\Content\Text\Markdown; use Friendica\Core\Addon; use Friendica\Core\Cache; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\Database\DBStructure; use Friendica\Model\Item; @@ -64,7 +65,7 @@ function advancedcontentfilter_install() DBStructure::update(false, true); - logger("installed advancedcontentfilter"); + Logger::log("installed advancedcontentfilter"); } function advancedcontentfilter_uninstall() diff --git a/blackout/blackout.php b/blackout/blackout.php index 9b2d5b625..dc19edda1 100644 --- a/blackout/blackout.php +++ b/blackout/blackout.php @@ -52,6 +52,7 @@ use Friendica\Core\Config; use Friendica\Core\Addon; use Friendica\Core\L10n; +use Friendica\Core\Logger; function blackout_install() { Addon::registerHook('page_header', 'addon/blackout/blackout.php', 'blackout_redirect'); @@ -84,7 +85,7 @@ function blackout_redirect ($a, $b) { $date2 = 0; } if (( $date1 <= $now ) && ( $now <= $date2 )) { - logger('redirecting user to blackout page'); + Logger::log('redirecting user to blackout page'); System::externalRedirect($myurl); } } diff --git a/blogger/blogger.php b/blogger/blogger.php index 00563c3ad..4de65d558 100644 --- a/blogger/blogger.php +++ b/blogger/blogger.php @@ -10,6 +10,7 @@ use Friendica\App; use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Util\Network; @@ -202,12 +203,12 @@ function blogger_send(App $a, array &$b) EOT; - logger('blogger: data: ' . $xml, LOGGER_DATA); + Logger::log('blogger: data: ' . $xml, LOGGER_DATA); if ($bl_blog !== 'test') { $x = Network::post($bl_blog, $xml)->getBody(); } - logger('posted to blogger: ' . (($x) ? $x : ''), LOGGER_DEBUG); + Logger::log('posted to blogger: ' . (($x) ? $x : ''), LOGGER_DEBUG); } } diff --git a/buffer/buffer.php b/buffer/buffer.php index 048a27daf..b5c17e4a5 100644 --- a/buffer/buffer.php +++ b/buffer/buffer.php @@ -12,6 +12,7 @@ use Friendica\Content\Text\Plaintext; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Database\DBA; @@ -112,7 +113,7 @@ function buffer_connect(App $a) if (!$buffer->ok) { $o .= 'Connect to Buffer!'; } else { - logger("buffer_connect: authenticated"); + Logger::log("buffer_connect: authenticated"); $o .= L10n::t("You are now authenticated to buffer. "); $o .= '
' . L10n::t("return to the connector page") . ''; PConfig::set(local_user(), 'buffer','access_token', $buffer->access_token); @@ -298,7 +299,7 @@ function buffer_send(App $a, array &$b) $profiles = $buffer->go('/profiles'); if (is_array($profiles)) { - logger("Will send these parameter ".print_r($b, true), LOGGER_DEBUG); + Logger::log("Will send these parameter ".print_r($b, true), LOGGER_DEBUG); foreach ($profiles as $profile) { if (!$profile->default) @@ -357,7 +358,7 @@ function buffer_send(App $a, array &$b) } $post = ItemContent::getPlaintextPost($item, $limit, $includedlinks, $htmlmode); - logger("buffer_send: converted message ".$b["id"]." result: ".print_r($post, true), LOGGER_DEBUG); + Logger::log("buffer_send: converted message ".$b["id"]." result: ".print_r($post, true), LOGGER_DEBUG); // The image proxy is used as a sanitizer. Buffer seems to be really picky about pictures if (isset($post["image"])) { @@ -407,9 +408,9 @@ function buffer_send(App $a, array &$b) } //print_r($message); - logger("buffer_send: data for message " . $b["id"] . ": " . print_r($message, true), LOGGER_DEBUG); + Logger::log("buffer_send: data for message " . $b["id"] . ": " . print_r($message, true), LOGGER_DEBUG); $ret = $buffer->go('/updates/create', $message); - logger("buffer_send: send message " . $b["id"] . " result: " . print_r($ret, true), LOGGER_DEBUG); + Logger::log("buffer_send: send message " . $b["id"] . " result: " . print_r($ret, true), LOGGER_DEBUG); } } } diff --git a/catavatar/catavatar.php b/catavatar/catavatar.php index b321ae330..07f21527d 100644 --- a/catavatar/catavatar.php +++ b/catavatar/catavatar.php @@ -10,6 +10,7 @@ use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\Worker; use Friendica\Database\DBA; @@ -28,7 +29,7 @@ function catavatar_install() Addon::registerHook('addon_settings', 'addon/catavatar/catavatar.php', 'catavatar_addon_settings'); Addon::registerHook('addon_settings_post', 'addon/catavatar/catavatar.php', 'catavatar_addon_settings_post'); - logger('registered catavatar'); + Logger::log('registered catavatar'); } /** @@ -40,7 +41,7 @@ function catavatar_uninstall() Addon::unregisterHook('addon_settings', 'addon/catavatar/catavatar.php', 'catavatar_addon_settings'); Addon::unregisterHook('addon_settings_post', 'addon/catavatar/catavatar.php', 'catavatar_addon_settings_post'); - logger('unregistered catavatar'); + Logger::log('unregistered catavatar'); } /** diff --git a/diaspora/diaspora.php b/diaspora/diaspora.php index 44bc1f744..508655fd9 100644 --- a/diaspora/diaspora.php +++ b/diaspora/diaspora.php @@ -13,6 +13,7 @@ use Friendica\App; use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Database\DBA; @@ -72,7 +73,7 @@ function diaspora_queue_hook(App $a, &$b) { continue; } - logger('diaspora_queue: run'); + Logger::log('diaspora_queue: run'); $r = q("SELECT `user`.* FROM `user` LEFT JOIN `contact` on `contact`.`uid` = `user`.`uid` WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1", @@ -92,37 +93,37 @@ function diaspora_queue_hook(App $a, &$b) { $success = false; if ($handle && $password) { - logger('diaspora_queue: able to post for user '.$handle); + Logger::log('diaspora_queue: able to post for user '.$handle); $z = unserialize($x['content']); $post = $z['post']; - logger('diaspora_queue: post: '.$post, LOGGER_DATA); + Logger::log('diaspora_queue: post: '.$post, LOGGER_DATA); try { - logger('diaspora_queue: prepare', LOGGER_DEBUG); + Logger::log('diaspora_queue: prepare', LOGGER_DEBUG); $conn = new Diaspora_Connection($handle, $password); - logger('diaspora_queue: try to log in '.$handle, LOGGER_DEBUG); + Logger::log('diaspora_queue: try to log in '.$handle, LOGGER_DEBUG); $conn->logIn(); - logger('diaspora_queue: try to send '.$body, LOGGER_DEBUG); + Logger::log('diaspora_queue: try to send '.$body, LOGGER_DEBUG); $conn->provider = $hostname; $conn->postStatusMessage($post, $aspect); - logger('diaspora_queue: send '.$userdata['uid'].' success', LOGGER_DEBUG); + Logger::log('diaspora_queue: send '.$userdata['uid'].' success', LOGGER_DEBUG); $success = true; Queue::removeItem($x['id']); } catch (Exception $e) { - logger("diaspora_queue: Send ".$userdata['uid']." failed: ".$e->getMessage(), LOGGER_DEBUG); + Logger::log("diaspora_queue: Send ".$userdata['uid']." failed: ".$e->getMessage(), LOGGER_DEBUG); } } else { - logger('diaspora_queue: send '.$userdata['uid'].' missing username or password', LOGGER_DEBUG); + Logger::log('diaspora_queue: send '.$userdata['uid'].' missing username or password', LOGGER_DEBUG); } if (!$success) { - logger('diaspora_queue: delayed'); + Logger::log('diaspora_queue: delayed'); Queue::updateTime($x['id']); } } @@ -289,7 +290,7 @@ function diaspora_send(App $a, array &$b) { $hostname = $a->getHostName(); - logger('diaspora_send: invoked'); + Logger::log('diaspora_send: invoked'); if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { return; @@ -311,14 +312,14 @@ function diaspora_send(App $a, array &$b) return; } - logger('diaspora_send: prepare posting', LOGGER_DEBUG); + Logger::log('diaspora_send: prepare posting', LOGGER_DEBUG); $handle = PConfig::get($b['uid'],'diaspora','handle'); $password = PConfig::get($b['uid'],'diaspora','password'); $aspect = PConfig::get($b['uid'],'diaspora','aspect'); if ($handle && $password) { - logger('diaspora_send: all values seem to be okay', LOGGER_DEBUG); + Logger::log('diaspora_send: all values seem to be okay', LOGGER_DEBUG); $tag_arr = []; $tags = ''; @@ -363,20 +364,20 @@ function diaspora_send(App $a, array &$b) require_once "addon/diaspora/diasphp.php"; try { - logger('diaspora_send: prepare', LOGGER_DEBUG); + Logger::log('diaspora_send: prepare', LOGGER_DEBUG); $conn = new Diaspora_Connection($handle, $password); - logger('diaspora_send: try to log in '.$handle, LOGGER_DEBUG); + Logger::log('diaspora_send: try to log in '.$handle, LOGGER_DEBUG); $conn->logIn(); - logger('diaspora_send: try to send '.$body, LOGGER_DEBUG); + Logger::log('diaspora_send: try to send '.$body, LOGGER_DEBUG); $conn->provider = $hostname; $conn->postStatusMessage($body, $aspect); - logger('diaspora_send: success'); + Logger::log('diaspora_send: success'); } catch (Exception $e) { - logger("diaspora_send: Error submitting the post: " . $e->getMessage()); + Logger::log("diaspora_send: Error submitting the post: " . $e->getMessage()); - logger('diaspora_send: requeueing '.$b['uid'], LOGGER_DEBUG); + Logger::log('diaspora_send: requeueing '.$b['uid'], LOGGER_DEBUG); $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", $b['uid']); if (count($r)) diff --git a/dwpost/dwpost.php b/dwpost/dwpost.php index bc8959fc3..462aaf45b 100644 --- a/dwpost/dwpost.php +++ b/dwpost/dwpost.php @@ -12,6 +12,7 @@ use Friendica\App; use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Database\DBA; use Friendica\Util\DateTimeFormat; @@ -225,13 +226,13 @@ function dwpost_send(App $a, array &$b) EOT; - logger('dwpost: data: ' . $xml, LOGGER_DATA); + Logger::log('dwpost: data: ' . $xml, LOGGER_DATA); if ($dw_blog !== 'test') { $x = Network::post($dw_blog, $xml, ["Content-Type: text/xml"])->getBody(); } - logger('posted to dreamwidth: ' . ($x) ? $x : '', LOGGER_DEBUG); + Logger::log('posted to dreamwidth: ' . ($x) ? $x : '', LOGGER_DEBUG); } } diff --git a/fromapp/fromapp.php b/fromapp/fromapp.php index 6a33cd037..f2b0f1fcd 100644 --- a/fromapp/fromapp.php +++ b/fromapp/fromapp.php @@ -8,6 +8,7 @@ */ use Friendica\Core\Addon; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; function fromapp_install() @@ -15,7 +16,7 @@ function fromapp_install() Addon::registerHook('post_local', 'addon/fromapp/fromapp.php', 'fromapp_post_hook'); Addon::registerHook('addon_settings', 'addon/fromapp/fromapp.php', 'fromapp_settings'); Addon::registerHook('addon_settings_post', 'addon/fromapp/fromapp.php', 'fromapp_settings_post'); - logger("installed fromapp"); + Logger::log("installed fromapp"); } @@ -24,7 +25,7 @@ function fromapp_uninstall() Addon::unregisterHook('post_local', 'addon/fromapp/fromapp.php', 'fromapp_post_hook'); Addon::unregisterHook('addon_settings', 'addon/fromapp/fromapp.php', 'fromapp_settings'); Addon::unregisterHook('addon_settings_post', 'addon/fromapp/fromapp.php', 'fromapp_settings_post'); - logger("removed fromapp"); + Logger::log("removed fromapp"); } function fromapp_settings_post($a, $post) diff --git a/fromgplus/fromgplus.php b/fromgplus/fromgplus.php index 9dc48753f..a964954ab 100644 --- a/fromgplus/fromgplus.php +++ b/fromgplus/fromgplus.php @@ -12,6 +12,7 @@ define('FROMGPLUS_DEFAULT_POLL_INTERVAL', 30); // given in minutes use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Object\Image; @@ -126,25 +127,25 @@ function fromgplus_cron($a,$b) { if($last) { $next = $last + ($poll_interval * 60); if($next > time()) { - logger('fromgplus: poll intervall not reached'); + Logger::log('fromgplus: poll intervall not reached'); return; } } - logger('fromgplus: cron_start'); + Logger::log('fromgplus: cron_start'); $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'fromgplus' AND `k` = 'enable' AND `v` = '1' ORDER BY RAND() "); if(count($r)) { foreach($r as $rr) { $account = PConfig::get($rr['uid'],'fromgplus','account'); if ($account) { - logger('fromgplus: fetching for user '.$rr['uid']); + Logger::log('fromgplus: fetching for user '.$rr['uid']); fromgplus_fetch($a, $rr['uid']); } } } - logger('fromgplus: cron_end'); + Logger::log('fromgplus: cron_end'); Config::set('fromgplus','last_poll', time()); } @@ -190,15 +191,15 @@ function fromgplus_post($a, $uid, $source, $body, $location, $coord, $id) { $_REQUEST['coord'] = $coord; if (($_REQUEST['title'] == "") && ($_REQUEST['body'] == "")) { - logger('fromgplus: empty post for user '.$uid." ".print_r($_REQUEST, true)); + Logger::log('fromgplus: empty post for user '.$uid." ".print_r($_REQUEST, true)); return; } require_once('mod/item.php'); //print_r($_REQUEST); - logger('fromgplus: posting for user '.$uid." ".print_r($_REQUEST, true)); + Logger::log('fromgplus: posting for user '.$uid." ".print_r($_REQUEST, true)); item_post($a); - logger('fromgplus: done for user '.$uid); + Logger::log('fromgplus: done for user '.$uid); } function fromgplus_html2bbcode($html) { @@ -472,7 +473,7 @@ function fromgplus_fetch($a, $uid) { // Don't publish items that are too young if (strtotime($item->published) > (time() - 3*60)) { - logger('fromgplus_fetch: item too new '.$item->published); + Logger::log('fromgplus_fetch: item too new '.$item->published); continue; } diff --git a/geocoordinates/geocoordinates.php b/geocoordinates/geocoordinates.php index 89ccd8839..7058e3ec9 100644 --- a/geocoordinates/geocoordinates.php +++ b/geocoordinates/geocoordinates.php @@ -9,6 +9,7 @@ use Friendica\Core\Addon; use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Util\Network; function geocoordinates_install() @@ -54,25 +55,25 @@ function geocoordinates_resolve_item(&$item) $s = Network::fetchUrl("https://api.opencagedata.com/geocode/v1/json?q=".$coords[0].",".$coords[1]."&key=".$key."&language=".$language); if (!$s) { - logger("API could not be queried", LOGGER_DEBUG); + Logger::log("API could not be queried", LOGGER_DEBUG); return; } $data = json_decode($s); if ($data->status->code != "200") { - logger("API returned error ".$data->status->code." ".$data->status->message, LOGGER_DEBUG); + Logger::log("API returned error ".$data->status->code." ".$data->status->message, LOGGER_DEBUG); return; } if (($data->total_results == 0) || (count($data->results) == 0)) { - logger("No results found for coordinates ".$item["coord"], LOGGER_DEBUG); + Logger::log("No results found for coordinates ".$item["coord"], LOGGER_DEBUG); return; } $item["location"] = $data->results[0]->formatted; - logger("Got location for coordinates ".$coords[0]."-".$coords[1].": ".$item["location"], LOGGER_DEBUG); + Logger::log("Got location for coordinates ".$coords[0]."-".$coords[1].": ".$item["location"], LOGGER_DEBUG); if ($item["location"] != "") Cache::set("geocoordinates:".$language.":".$coords[0]."-".$coords[1], $item["location"]); diff --git a/geonames/geonames.php b/geonames/geonames.php index dc6e116b7..9486d4e65 100644 --- a/geonames/geonames.php +++ b/geonames/geonames.php @@ -24,6 +24,7 @@ use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Util\Network; use Friendica\Util\XML; @@ -52,7 +53,7 @@ function geonames_install() { Addon::registerHook('addon_settings', 'addon/geonames/geonames.php', 'geonames_addon_admin'); Addon::registerHook('addon_settings_post', 'addon/geonames/geonames.php', 'geonames_addon_admin_post'); - logger("installed geonames"); + Logger::log("installed geonames"); } @@ -72,7 +73,7 @@ function geonames_uninstall() { Addon::unregisterHook('addon_settings_post', 'addon/geonames/geonames.php', 'geonames_addon_admin_post'); - logger("removed geonames"); + Logger::log("removed geonames"); } function geonames_load_config(\Friendica\App $a) @@ -91,7 +92,7 @@ function geonames_post_hook($a, &$item) { * */ - logger('geonames invoked'); + Logger::log('geonames invoked'); if(! local_user()) /* non-zero if this is a logged in user of this system */ return; @@ -132,7 +133,7 @@ function geonames_post_hook($a, &$item) { $item['location'] = $xml->geoname->name . ', ' . $xml->geoname->countryName; -// logger('geonames : ' . print_r($xml,true), LOGGER_DATA); +// Logger::log('geonames : ' . print_r($xml,true), LOGGER_DATA); return; } diff --git a/gnot/gnot.php b/gnot/gnot.php index 2c4555ba3..3cab85393 100644 --- a/gnot/gnot.php +++ b/gnot/gnot.php @@ -9,6 +9,7 @@ */ use Friendica\Core\Addon; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; function gnot_install() { @@ -17,7 +18,7 @@ function gnot_install() { Addon::registerHook('addon_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post'); Addon::registerHook('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail'); - logger("installed gnot"); + Logger::log("installed gnot"); } @@ -28,7 +29,7 @@ function gnot_uninstall() { Addon::unregisterHook('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail'); - logger("removed gnot"); + Logger::log("removed gnot"); } diff --git a/googlemaps/googlemaps.php b/googlemaps/googlemaps.php index e294c8e0e..7cccb6502 100644 --- a/googlemaps/googlemaps.php +++ b/googlemaps/googlemaps.php @@ -8,19 +8,20 @@ */ use Friendica\Core\Addon; use Friendica\Core\Cache; +use Friendica\Core\Logger function googlemaps_install() { Addon::registerHook('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location'); - logger("installed googlemaps"); + Logger::log("installed googlemaps"); } function googlemaps_uninstall() { Addon::unregisterHook('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location'); - logger("removed googlemaps"); + Logger::log("removed googlemaps"); } function googlemaps_location($a, &$item) diff --git a/gravatar/gravatar.php b/gravatar/gravatar.php index 9a23edfe6..e5a59b264 100644 --- a/gravatar/gravatar.php +++ b/gravatar/gravatar.php @@ -11,6 +11,7 @@ use Friendica\BaseModule; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\Util\Security; @@ -21,7 +22,7 @@ function gravatar_install() { Addon::registerHook('load_config', 'addon/gravatar/gravatar.php', 'gravatar_load_config'); Addon::registerHook('avatar_lookup', 'addon/gravatar/gravatar.php', 'gravatar_lookup'); - logger("registered gravatar in avatar_lookup hook"); + Logger::log("registered gravatar in avatar_lookup hook"); } /** @@ -31,7 +32,7 @@ function gravatar_uninstall() { Addon::unregisterHook('load_config', 'addon/gravatar/gravatar.php', 'gravatar_load_config'); Addon::unregisterHook('avatar_lookup', 'addon/gravatar/gravatar.php', 'gravatar_lookup'); - logger("unregistered gravatar in avatar_lookup hook"); + Logger::log("unregistered gravatar in avatar_lookup hook"); } function gravatar_load_config(App $a) diff --git a/group_text/group_text.php b/group_text/group_text.php index 3f91ff355..76bb03fdf 100644 --- a/group_text/group_text.php +++ b/group_text/group_text.php @@ -7,6 +7,7 @@ */ use Friendica\Core\Addon; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; function group_text_install() { @@ -14,7 +15,7 @@ function group_text_install() { Addon::registerHook('addon_settings', 'addon/group_text/group_text.php', 'group_text_settings'); Addon::registerHook('addon_settings_post', 'addon/group_text/group_text.php', 'group_text_settings_post'); - logger("installed group_text"); + Logger::log("installed group_text"); } @@ -24,7 +25,7 @@ function group_text_uninstall() { Addon::unregisterHook('addon_settings_post', 'addon/group_text/group_text.php', 'group_text_settings_post'); - logger("removed group_text"); + Logger::log("removed group_text"); } diff --git a/ifttt/ifttt.php b/ifttt/ifttt.php index 2e48319ab..8ba7428cb 100644 --- a/ifttt/ifttt.php +++ b/ifttt/ifttt.php @@ -13,6 +13,7 @@ require_once 'include/text.php'; use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Database\DBA; @@ -103,16 +104,16 @@ function ifttt_post(App $a) $user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname]); if (!DBA::isResult($user)) { - logger('User ' . $nickname . ' not found.', LOGGER_DEBUG); + Logger::log('User ' . $nickname . ' not found.', LOGGER_DEBUG); return; } $uid = $user['uid']; - logger('Received a post for user ' . $uid . ' from ifttt ' . print_r($_REQUEST, true), LOGGER_DEBUG); + Logger::log('Received a post for user ' . $uid . ' from ifttt ' . print_r($_REQUEST, true), LOGGER_DEBUG); if (!isset($_REQUEST['key'])) { - logger('No key found.'); + Logger::log('No key found.'); return; } @@ -120,7 +121,7 @@ function ifttt_post(App $a) // Check the key if ($key != PConfig::get($uid, 'ifttt', 'key')) { - logger('Invalid key for user ' . $uid, LOGGER_DEBUG); + Logger::log('Invalid key for user ' . $uid, LOGGER_DEBUG); return; } @@ -131,7 +132,7 @@ function ifttt_post(App $a) } if (!in_array($item['type'], ['status', 'link', 'photo'])) { - logger('Unknown item type ' . $item['type'], LOGGER_DEBUG); + Logger::log('Unknown item type ' . $item['type'], LOGGER_DEBUG); return; } diff --git a/ijpost/ijpost.php b/ijpost/ijpost.php index 3dcfb31fe..13ede61fe 100644 --- a/ijpost/ijpost.php +++ b/ijpost/ijpost.php @@ -11,6 +11,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; @@ -221,12 +222,12 @@ function ijpost_send(&$a, &$b) EOT; - logger('ijpost: data: ' . $xml, LOGGER_DATA); + Logger::log('ijpost: data: ' . $xml, LOGGER_DATA); if ($ij_blog !== 'test') { $x = Network::post($ij_blog, $xml, ["Content-Type: text/xml"])->getBody(); } - logger('posted to insanejournal: ' . $x ? $x : '', LOGGER_DEBUG); + Logger::log('posted to insanejournal: ' . $x ? $x : '', LOGGER_DEBUG); } } diff --git a/impressum/impressum.php b/impressum/impressum.php index 907751165..2cac33fa5 100644 --- a/impressum/impressum.php +++ b/impressum/impressum.php @@ -11,20 +11,21 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Util\Proxy as ProxyUtils; function impressum_install() { Addon::registerHook('load_config', 'addon/impressum/impressum.php', 'impressum_load_config'); Addon::registerHook('about_hook', 'addon/impressum/impressum.php', 'impressum_show'); Addon::registerHook('page_end', 'addon/impressum/impressum.php', 'impressum_footer'); - logger("installed impressum Addon"); + Logger::log("installed impressum Addon"); } function impressum_uninstall() { Addon::unregisterHook('load_config', 'addon/impressum/impressum.php', 'impressum_load_config'); Addon::unregisterHook('about_hook', 'addon/impressum/impressum.php', 'impressum_show'); Addon::unregisterHook('page_end', 'addon/impressum/impressum.php', 'impressum_footer'); - logger("uninstalled impressum Addon"); + Logger::log("uninstalled impressum Addon"); } function impressum_module() { diff --git a/jappixmini/jappixmini.php b/jappixmini/jappixmini.php index 8111f9fd8..e2ef01d28 100644 --- a/jappixmini/jappixmini.php +++ b/jappixmini/jappixmini.php @@ -66,6 +66,7 @@ use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Database\DBA; @@ -584,7 +585,7 @@ function jappixmini_cron(App $a, $d) // go through list of users with jabber enabled $users = q("SELECT `uid` FROM `pconfig` WHERE `cat`='jappixmini' AND (`k`='autosubscribe' OR `k`='autoapprove') AND `v`='1'"); - logger("jappixmini: Update list of contacts' jabber accounts for " . count($users) . " users."); + Logger::log("jappixmini: Update list of contacts' jabber accounts for " . count($users) . " users."); if (!count($users)) { return; diff --git a/js_upload/js_upload.php b/js_upload/js_upload.php index adeba838c..9762e8996 100644 --- a/js_upload/js_upload.php +++ b/js_upload/js_upload.php @@ -17,6 +17,7 @@ use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; function js_upload_install() { Addon::registerHook('photo_upload_form', 'addon/js_upload/js_upload.php', 'js_upload_form'); @@ -159,7 +160,7 @@ function js_upload_post_init(&$a,&$b) { $a->data['upload_jsonresponse'] = htmlspecialchars(json_encode($result), ENT_NOQUOTES); if(isset($result['error'])) { - logger('mod/photos.php: photos_post(): error uploading photo: ' . $result['error'] , 'LOGGER_DEBUG'); + Logger::log('mod/photos.php: photos_post(): error uploading photo: ' . $result['error'] , 'LOGGER_DEBUG'); echo json_encode($result); killme(); } @@ -181,7 +182,7 @@ function js_upload_post_file(&$a,&$b) { function js_upload_post_end(&$a,&$b) { -logger('upload_post_end'); +Logger::log('upload_post_end'); if(x($a->data,'upload_jsonresponse')) { echo $a->data['upload_jsonresponse']; killme(); diff --git a/krynn/krynn.php b/krynn/krynn.php index 4b6e1f7f7..97871c3a3 100644 --- a/krynn/krynn.php +++ b/krynn/krynn.php @@ -11,6 +11,7 @@ */ use Friendica\Core\Addon; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; function krynn_install() { @@ -35,7 +36,7 @@ function krynn_install() { Addon::registerHook('addon_settings', 'addon/krynn/krynn.php', 'krynn_settings'); Addon::registerHook('addon_settings_post', 'addon/krynn/krynn.php', 'krynn_settings_post'); - logger("installed krynn"); + Logger::log("installed krynn"); } @@ -54,7 +55,7 @@ function krynn_uninstall() { Addon::unregisterHook('addon_settings_post', 'addon/krynn/krynn.php', 'krynn_settings_post'); - logger("removed krynn"); + Logger::log("removed krynn"); } @@ -70,7 +71,7 @@ function krynn_post_hook($a, &$item) { * */ - logger('krynn invoked'); + Logger::log('krynn invoked'); if(! local_user()) /* non-zero if this is a logged in user of this system */ return; diff --git a/ldapauth/ldapauth.php b/ldapauth/ldapauth.php index 514fb1d1a..eb8cafc41 100644 --- a/ldapauth/ldapauth.php +++ b/ldapauth/ldapauth.php @@ -55,6 +55,7 @@ */ use Friendica\Core\Addon; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Model\User; function ldapauth_install() @@ -99,28 +100,28 @@ function ldapauth_authenticate($username, $password) $ldap_autocreateaccount_nameattribute = Config::get('ldapauth', 'ldap_autocreateaccount_nameattribute'); if (!(strlen($password) && function_exists('ldap_connect') && strlen($ldap_server))) { - logger("ldapauth: not configured or missing php-ldap module"); + Logger::log("ldapauth: not configured or missing php-ldap module"); return false; } $connect = @ldap_connect($ldap_server); if ($connect === false) { - logger("ldapauth: could not connect to $ldap_server"); + Logger::log("ldapauth: could not connect to $ldap_server"); return false; } @ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3); @ldap_set_option($connect, LDAP_OPT_REFERRALS, 0); if ((@ldap_bind($connect, $ldap_binddn, $ldap_bindpw)) === false) { - logger("ldapauth: could not bind $ldap_server as $ldap_binddn"); + Logger::log("ldapauth: could not bind $ldap_server as $ldap_binddn"); return false; } $res = @ldap_search($connect, $ldap_searchdn, $ldap_userattr . '=' . $username); if (!$res) { - logger("ldapauth: $ldap_userattr=$username,$ldap_searchdn not found"); + Logger::log("ldapauth: $ldap_userattr=$username,$ldap_searchdn not found"); return false; } @@ -161,13 +162,13 @@ function ldapauth_authenticate($username, $password) @ldap_close($connect); if ($eno === 32) { - logger("ldapauth: access control group Does Not Exist"); + Logger::log("ldapauth: access control group Does Not Exist"); return false; } elseif ($eno === 16) { - logger('ldapauth: membership attribute does not exist in access control group'); + Logger::log('ldapauth: membership attribute does not exist in access control group'); return false; } else { - logger('ldapauth: error: ' . $err); + Logger::log('ldapauth: error: ' . $err); return false; } } elseif ($r === false) { @@ -189,12 +190,12 @@ function ldap_autocreateaccount($ldap_autocreateaccount, $username, $password, $ try { User::create($arr); - logger("ldapauth: account " . $username . " created"); + Logger::log("ldapauth: account " . $username . " created"); } catch (Exception $ex) { - logger("ldapauth: account " . $username . " was not created ! : " . $ex->getMessage()); + Logger::log("ldapauth: account " . $username . " was not created ! : " . $ex->getMessage()); } } else { - logger("ldapauth: unable to create account, no email or nickname found"); + Logger::log("ldapauth: unable to create account, no email or nickname found"); } } } diff --git a/leistungsschutzrecht/leistungsschutzrecht.php b/leistungsschutzrecht/leistungsschutzrecht.php index c0625ccbc..020c3af3b 100644 --- a/leistungsschutzrecht/leistungsschutzrecht.php +++ b/leistungsschutzrecht/leistungsschutzrecht.php @@ -7,6 +7,7 @@ */ use Friendica\Core\Addon; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Util\Network; function leistungsschutzrecht_install() { @@ -163,7 +164,7 @@ function leistungsschutzrecht_cron($a,$b) { if($last) { $next = $last + 86400; if($next > time()) { - logger('poll intervall not reached'); + Logger::log('poll intervall not reached'); return; } } diff --git a/libertree/libertree.php b/libertree/libertree.php index 19512bc54..0804476c3 100644 --- a/libertree/libertree.php +++ b/libertree/libertree.php @@ -9,6 +9,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Database\DBA; use Friendica\Util\Network; @@ -157,7 +158,7 @@ function libertree_post_local(&$a,&$b) { function libertree_send(&$a,&$b) { - logger('libertree_send: invoked'); + Logger::log('libertree_send: invoked'); if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { return; @@ -232,6 +233,6 @@ function libertree_send(&$a,&$b) { ]; $result = Network::post($ltree_blog, $params)->getBody(); - logger('libertree: ' . $result); + Logger::log('libertree: ' . $result); } } diff --git a/libravatar/libravatar.php b/libravatar/libravatar.php index bc6715486..80c9e4c5b 100644 --- a/libravatar/libravatar.php +++ b/libravatar/libravatar.php @@ -11,6 +11,7 @@ use Friendica\BaseModule; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\Util\Security; @@ -21,7 +22,7 @@ function libravatar_install() { Addon::registerHook('load_config', 'addon/libravatar/libravatar.php', 'libravatar_load_config'); Addon::registerHook('avatar_lookup', 'addon/libravatar/libravatar.php', 'libravatar_lookup'); - logger("registered libravatar in avatar_lookup hook"); + Logger::log("registered libravatar in avatar_lookup hook"); } /** @@ -31,7 +32,7 @@ function libravatar_uninstall() { Addon::unregisterHook('load_config', 'addon/libravatar/libravatar.php', 'libravatar_load_config'); Addon::unregisterHook('avatar_lookup', 'addon/libravatar/libravatar.php', 'libravatar_lookup'); - logger("unregistered libravatar in avatar_lookup hook"); + Logger::log("unregistered libravatar in avatar_lookup hook"); } function libravatar_load_config(App $a) diff --git a/ljpost/ljpost.php b/ljpost/ljpost.php index dfc1387b0..2473e74f9 100644 --- a/ljpost/ljpost.php +++ b/ljpost/ljpost.php @@ -11,6 +11,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; @@ -231,12 +232,12 @@ function ljpost_send(&$a,&$b) { EOT; - logger('ljpost: data: ' . $xml, LOGGER_DATA); + Logger::log('ljpost: data: ' . $xml, LOGGER_DATA); if ($lj_blog !== 'test') { $x = Network::post($lj_blog, $xml, ["Content-Type: text/xml"])->getBody(); } - logger('posted to livejournal: ' . ($x) ? $x : '', LOGGER_DEBUG); + Logger::log('posted to livejournal: ' . ($x) ? $x : '', LOGGER_DEBUG); } } diff --git a/mailstream/mailstream.php b/mailstream/mailstream.php index dc44b931d..bac15342a 100644 --- a/mailstream/mailstream.php +++ b/mailstream/mailstream.php @@ -10,6 +10,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Database\DBA; use Friendica\Util\Network; @@ -94,7 +95,7 @@ function mailstream_generate_id($a, $uri) { $host = $a->getHostName(); $resource = hash('md5', $uri); $message_id = "<" . $resource . "@" . $host . ">"; - logger('mailstream: Generated message ID ' . $message_id . ' for URI ' . $uri, LOGGER_DEBUG); + Logger::log('mailstream: Generated message ID ' . $message_id . ' for URI ' . $uri, LOGGER_DEBUG); return $message_id; } @@ -123,16 +124,16 @@ function mailstream_post_hook(&$a, &$item) { intval($item['contact-id']), DBA::escape($item['uri']), DBA::escape($message_id)); $r = q('SELECT * FROM `mailstream_item` WHERE `uid` = %d AND `contact-id` = %d AND `uri` = "%s"', intval($item['uid']), intval($item['contact-id']), DBA::escape($item['uri'])); if (count($r) != 1) { - logger('mailstream_post_remote_hook: Unexpected number of items returned from mailstream_item', LOGGER_INFO); + Logger::log('mailstream_post_remote_hook: Unexpected number of items returned from mailstream_item', LOGGER_INFO); return; } $ms_item = $r[0]; - logger('mailstream_post_remote_hook: created mailstream_item ' + Logger::log('mailstream_post_remote_hook: created mailstream_item ' . $ms_item['id'] . ' for item ' . $item['uri'] . ' ' . $item['uid'] . ' ' . $item['contact-id'], LOGGER_DATA); $user = mailstream_get_user($item['uid']); if (!$user) { - logger('mailstream_post_remote_hook: no user ' . $item['uid'], LOGGER_INFO); + Logger::log('mailstream_post_remote_hook: no user ' . $item['uid'], LOGGER_INFO); return; } mailstream_send($a, $ms_item['message-id'], $item, $user); @@ -141,7 +142,7 @@ function mailstream_post_hook(&$a, &$item) { function mailstream_get_user($uid) { $r = q('SELECT * FROM `user` WHERE `uid` = %d', intval($uid)); if (count($r) != 1) { - logger('mailstream_post_remote_hook: Unexpected number of users returned', LOGGER_INFO); + Logger::log('mailstream_post_remote_hook: Unexpected number of users returned', LOGGER_INFO); return; } return $r[0]; @@ -298,11 +299,11 @@ function mailstream_send($a, $message_id, $item, $user) { if (!$mail->Send()) { throw new Exception($mail->ErrorInfo); } - logger('mailstream_send sent message ' . $mail->MessageID . ' ' . $mail->Subject, LOGGER_DEBUG); + Logger::log('mailstream_send sent message ' . $mail->MessageID . ' ' . $mail->Subject, LOGGER_DEBUG); } catch (phpmailerException $e) { - logger('mailstream_send PHPMailer exception sending message ' . $message_id . ': ' . $e->errorMessage(), LOGGER_INFO); + Logger::log('mailstream_send PHPMailer exception sending message ' . $message_id . ': ' . $e->errorMessage(), LOGGER_INFO); } catch (Exception $e) { - logger('mailstream_send exception sending message ' . $message_id . ': ' . $e->getMessage(), LOGGER_INFO); + Logger::log('mailstream_send exception sending message ' . $message_id . ': ' . $e->getMessage(), LOGGER_INFO); } // In case of failure, still set the item to completed. Otherwise // we'll just try to send it over and over again and it'll fail @@ -331,10 +332,10 @@ function mailstream_cron($a, $b) { // mailstream_post_remote_hook fails for some reason will this get // used, and in that case it's worth holding off a bit anyway. $ms_item_ids = q("SELECT `mailstream_item`.`message-id`, `mailstream_item`.`uri`, `item`.`id` FROM `mailstream_item` JOIN `item` ON (`mailstream_item`.`uid` = `item`.`uid` AND `mailstream_item`.`uri` = `item`.`uri` AND `mailstream_item`.`contact-id` = `item`.`contact-id`) WHERE `mailstream_item`.`completed` IS NULL AND `mailstream_item`.`created` < DATE_SUB(NOW(), INTERVAL 1 HOUR) AND `item`.`visible` = 1 ORDER BY `mailstream_item`.`created` LIMIT 100"); - logger('mailstream_cron processing ' . count($ms_item_ids) . ' items', LOGGER_DEBUG); + Logger::log('mailstream_cron processing ' . count($ms_item_ids) . ' items', LOGGER_DEBUG); foreach ($ms_item_ids as $ms_item_id) { if (!$ms_item_id['message-id'] || !strlen($ms_item_id['message-id'])) { - logger('mailstream_cron: Item ' . $ms_item_id['id'] . ' URI ' . $ms_item_id['uri'] . ' has no message-id', LOGGER_INFO); + Logger::log('mailstream_cron: Item ' . $ms_item_id['id'] . ' URI ' . $ms_item_id['uri'] . ' has no message-id', LOGGER_INFO); } $item = Item::selectFirst([], ['id' => $ms_item_id['id']]); $users = q("SELECT * FROM `user` WHERE `uid` = %d", intval($item['uid'])); @@ -343,7 +344,7 @@ function mailstream_cron($a, $b) { mailstream_send($a, $ms_item_id['message-id'], $item, $user); } else { - logger('mailstream_cron: Unable to find item ' . $ms_item_id['id'], LOGGER_INFO); + Logger::log('mailstream_cron: Unable to find item ' . $ms_item_id['id'], LOGGER_INFO); q("UPDATE `mailstream_item` SET `completed` = now() WHERE `message-id` = %d", intval($ms_item['message-id'])); } } @@ -412,5 +413,5 @@ function mailstream_tidy() { foreach ($r as $rr) { q('DELETE FROM mailstream_item WHERE id = %d', intval($rr['id'])); } - logger('mailstream_tidy: deleted ' . count($r) . ' old items', LOGGER_DEBUG); + Logger::log('mailstream_tidy: deleted ' . count($r) . ' old items', LOGGER_DEBUG); } diff --git a/newmemberwidget/newmemberwidget.php b/newmemberwidget/newmemberwidget.php index d7f38068c..f71f01b26 100644 --- a/newmemberwidget/newmemberwidget.php +++ b/newmemberwidget/newmemberwidget.php @@ -10,11 +10,12 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; function newmemberwidget_install() { Addon::registerHook( 'network_mod_init', 'addon/newmemberwidget/newmemberwidget.php', 'newmemberwidget_network_mod_init'); - logger('newmemberwidget installed'); + Logger::log('newmemberwidget installed'); } function newmemberwidget_uninstall() diff --git a/notifyall/notifyall.php b/notifyall/notifyall.php index 852972c37..a2eb2a879 100644 --- a/notifyall/notifyall.php +++ b/notifyall/notifyall.php @@ -12,16 +12,17 @@ use Friendica\App; use Friendica\Content\Text\BBCode; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Util\Emailer; function notifyall_install() { - logger("installed notifyall"); + Logger::log("installed notifyall"); } function notifyall_uninstall() { - logger("removed notifyall"); + Logger::log("removed notifyall"); } function notifyall_module() {} diff --git a/numfriends/numfriends.php b/numfriends/numfriends.php index 0cfea7366..9e22b0ea3 100644 --- a/numfriends/numfriends.php +++ b/numfriends/numfriends.php @@ -7,6 +7,7 @@ */ use Friendica\Core\Addon; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; function numfriends_install() { @@ -14,7 +15,7 @@ function numfriends_install() { Addon::registerHook('addon_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings'); Addon::registerHook('addon_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post'); - logger("installed numfriends"); + Logger::log("installed numfriends"); } @@ -24,7 +25,7 @@ function numfriends_uninstall() { Addon::unregisterHook('addon_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post'); - logger("removed numfriends"); + Logger::log("removed numfriends"); } /** diff --git a/openstreetmap/openstreetmap.php b/openstreetmap/openstreetmap.php index c8eb43a9d..bdecb5ca5 100644 --- a/openstreetmap/openstreetmap.php +++ b/openstreetmap/openstreetmap.php @@ -12,6 +12,7 @@ use Friendica\Core\Addon; use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Util\Network; @@ -29,7 +30,7 @@ function openstreetmap_install() Addon::registerHook('Map::getCoordinates', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_get_coordinates'); Addon::registerHook('page_header', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_alterheader'); - logger("installed openstreetmap"); + Logger::log("installed openstreetmap"); } function openstreetmap_uninstall() @@ -41,7 +42,7 @@ function openstreetmap_uninstall() Addon::unregisterHook('Map::getCoordinates', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_get_coordinates'); Addon::unregisterHook('page_header', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_alterheader'); - logger("removed openstreetmap"); + Logger::log("removed openstreetmap"); } function openstreetmap_load_config(\Friendica\App $a) @@ -165,8 +166,8 @@ function openstreetmap_generate_map(&$a, &$b) $lat = $b['lat']; // round($b['lat'], 5); $lon = $b['lon']; // round($b['lon'], 5); - logger('lat: ' . $lat, LOGGER_DATA); - logger('lon: ' . $lon, LOGGER_DATA); + Logger::log('lat: ' . $lat, LOGGER_DATA); + Logger::log('lon: ' . $lon, LOGGER_DATA); $cardlink = 'getBaseURL()."/images/friendica-256.png"; $params["redirect_uris"] = $a->getBaseURL()."/pumpio/connect"; - logger("pumpio_registerclient: ".$url." parameters ".print_r($params, true), LOGGER_DEBUG); + Logger::log("pumpio_registerclient: ".$url." parameters ".print_r($params, true), LOGGER_DEBUG); $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, false); @@ -128,10 +129,10 @@ function pumpio_registerclient(App $a, $host) if ($curl_info["http_code"] == "200") { $values = json_decode($s); - logger("pumpio_registerclient: success ".print_r($values, true), LOGGER_DEBUG); + Logger::log("pumpio_registerclient: success ".print_r($values, true), LOGGER_DEBUG); return $values; } - logger("pumpio_registerclient: failed: ".print_r($curl_info, true), LOGGER_DEBUG); + Logger::log("pumpio_registerclient: failed: ".print_r($curl_info, true), LOGGER_DEBUG); return false; } @@ -144,7 +145,7 @@ function pumpio_connect(App $a) $hostname = PConfig::get(local_user(), 'pumpio', 'host'); if ((($consumer_key == "") || ($consumer_secret == "")) && ($hostname != "")) { - logger("pumpio_connect: register client"); + Logger::log("pumpio_connect: register client"); $clientdata = pumpio_registerclient($a, $hostname); PConfig::set(local_user(), 'pumpio', 'consumer_key', $clientdata->client_id); PConfig::set(local_user(), 'pumpio', 'consumer_secret', $clientdata->client_secret); @@ -152,11 +153,11 @@ function pumpio_connect(App $a) $consumer_key = PConfig::get(local_user(), 'pumpio', 'consumer_key'); $consumer_secret = PConfig::get(local_user(), 'pumpio', 'consumer_secret'); - logger("pumpio_connect: ckey: ".$consumer_key." csecrect: ".$consumer_secret, LOGGER_DEBUG); + Logger::log("pumpio_connect: ckey: ".$consumer_key." csecrect: ".$consumer_secret, LOGGER_DEBUG); } if (($consumer_key == "") || ($consumer_secret == "")) { - logger("pumpio_connect: ".sprintf("Unable to register the client at the pump.io server '%s'.", $hostname)); + Logger::log("pumpio_connect: ".sprintf("Unable to register the client at the pump.io server '%s'.", $hostname)); $o .= L10n::t("Unable to register the client at the pump.io server '%s'.", $hostname); return $o; @@ -186,7 +187,7 @@ function pumpio_connect(App $a) if (($success = $client->Initialize())) { if (($success = $client->Process())) { if (strlen($client->access_token)) { - logger("pumpio_connect: otoken: ".$client->access_token." osecrect: ".$client->access_token_secret, LOGGER_DEBUG); + Logger::log("pumpio_connect: otoken: ".$client->access_token." osecrect: ".$client->access_token_secret, LOGGER_DEBUG); PConfig::set(local_user(), "pumpio", "oauth_token", $client->access_token); PConfig::set(local_user(), "pumpio", "oauth_token_secret", $client->access_token_secret); } @@ -198,11 +199,11 @@ function pumpio_connect(App $a) } if ($success) { - logger("pumpio_connect: authenticated"); + Logger::log("pumpio_connect: authenticated"); $o = L10n::t("You are now authenticated to pumpio."); $o .= '
'.L10n::t("return to the connector page").''; } else { - logger("pumpio_connect: could not connect"); + Logger::log("pumpio_connect: could not connect"); $o = 'Could not connect to pumpio. Refresh the page or try again later.'; } @@ -409,7 +410,7 @@ function pumpio_send(App $a, array &$b) return; } - logger("pumpio_send: parameter ".print_r($b, true), LOGGER_DATA); + Logger::log("pumpio_send: parameter ".print_r($b, true), LOGGER_DATA); if ($b['parent'] != $b['id']) { // Looking if its a reply to a pumpio post @@ -417,7 +418,7 @@ function pumpio_send(App $a, array &$b) $orig_post = Item::selectFirst([], $condition); if (!DBA::isResult($orig_post)) { - logger("pumpio_send: no pumpio post ".$b["parent"]); + Logger::log("pumpio_send: no pumpio post ".$b["parent"]); return; } else { $iscomment = true; @@ -427,7 +428,7 @@ function pumpio_send(App $a, array &$b) $receiver = pumpio_getreceiver($a, $b); - logger("pumpio_send: receiver ".print_r($receiver, true)); + Logger::log("pumpio_send: receiver ".print_r($receiver, true)); if (!count($receiver) && ($b['private'] || !strstr($b['postopts'], 'pumpio'))) { return; @@ -559,13 +560,13 @@ function pumpio_send(App $a, array &$b) } $post_id = $user->object->id; - logger('pumpio_send '.$username.': success '.$post_id); + Logger::log('pumpio_send '.$username.': success '.$post_id); if ($post_id && $iscomment) { - logger('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$b['id']); + Logger::log('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$b['id']); Item::update(['extid' => $post_id], ['id' => $b['id']]); } } else { - logger('pumpio_send '.$username.': '.$url.' general error: ' . print_r($user, true)); + Logger::log('pumpio_send '.$username.': '.$url.' general error: ' . print_r($user, true)); $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", $b['uid']); if (DBA::isResult($r)) { @@ -640,9 +641,9 @@ function pumpio_action(App $a, $uid, $uri, $action, $content = "") } if ($success) { - logger('pumpio_action '.$username.' '.$action.': success '.$uri); + Logger::log('pumpio_action '.$username.' '.$action.': success '.$uri); } else { - logger('pumpio_action '.$username.' '.$action.': general error: '.$uri.' '.print_r($user, true)); + Logger::log('pumpio_action '.$username.' '.$action.': general error: '.$uri.' '.print_r($user, true)); $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", $uid); if (DBA::isResult($r)) { @@ -671,16 +672,16 @@ function pumpio_sync(App $a) if ($last) { $next = $last + ($poll_interval * 60); if ($next > time()) { - logger('pumpio: poll intervall not reached'); + Logger::log('pumpio: poll intervall not reached'); return; } } - logger('pumpio: cron_start'); + Logger::log('pumpio: cron_start'); $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'pumpio' AND `k` = 'mirror' AND `v` = '1' ORDER BY RAND() "); if (DBA::isResult($r)) { foreach ($r as $rr) { - logger('pumpio: mirroring user '.$rr['uid']); + Logger::log('pumpio: mirroring user '.$rr['uid']); pumpio_fetchtimeline($a, $rr['uid']); } } @@ -698,12 +699,12 @@ function pumpio_sync(App $a) if ($abandon_days != 0) { $user = q("SELECT `login_date` FROM `user` WHERE uid=%d AND `login_date` >= '%s'", $rr['uid'], $abandon_limit); if (!DBA::isResult($user)) { - logger('abandoned account: timeline from user '.$rr['uid'].' will not be imported'); + Logger::log('abandoned account: timeline from user '.$rr['uid'].' will not be imported'); continue; } } - logger('pumpio: importing timeline from user '.$rr['uid']); + Logger::log('pumpio: importing timeline from user '.$rr['uid']); pumpio_fetchinbox($a, $rr['uid']); // check for new contacts once a day @@ -721,7 +722,7 @@ function pumpio_sync(App $a) } } - logger('pumpio: cron_end'); + Logger::log('pumpio: cron_end'); Config::set('pumpio', 'last_poll', time()); } @@ -766,7 +767,7 @@ function pumpio_fetchtimeline(App $a, $uid) $url = 'https://'.$hostname.'/api/user/'.$username.'/feed/major'; - logger('pumpio: fetching for user '.$uid.' '.$url.' C:'.$client->client_id.' CS:'.$client->client_secret.' T:'.$client->access_token.' TS:'.$client->access_token_secret); + Logger::log('pumpio: fetching for user '.$uid.' '.$url.' C:'.$client->client_id.' CS:'.$client->client_secret.' T:'.$client->access_token.' TS:'.$client->access_token_secret); $useraddr = $username.'@'.$hostname; @@ -778,7 +779,7 @@ function pumpio_fetchtimeline(App $a, $uid) } if (!$success) { - logger('pumpio: error fetching posts for user '.$uid." ".$useraddr." ".print_r($user, true)); + Logger::log('pumpio: error fetching posts for user '.$uid." ".$useraddr." ".print_r($user, true)); return; } @@ -847,12 +848,12 @@ function pumpio_fetchtimeline(App $a, $uid) } } - logger('pumpio: posting for user '.$uid); + Logger::log('pumpio: posting for user '.$uid); require_once('mod/item.php'); item_post($a); - logger('pumpio: posting done - user '.$uid); + Logger::log('pumpio: posting done - user '.$uid); } } } @@ -896,9 +897,9 @@ function pumpio_dounlike(App $a, $uid, $self, $post, $own_id) Item::delete(['verb' => ACTIVITY_LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']]); if (DBA::isResult($r)) { - logger("pumpio_dounlike: unliked existing like. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']); + Logger::log("pumpio_dounlike: unliked existing like. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']); } else { - logger("pumpio_dounlike: not found. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']); + Logger::log("pumpio_dounlike: not found. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']); } } @@ -907,7 +908,7 @@ function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion = require_once('include/items.php'); if (empty($post->object->id)) { - logger('Got empty like: '.print_r($post, true), LOGGER_DEBUG); + Logger::log('Got empty like: '.print_r($post, true), LOGGER_DEBUG); return; } @@ -950,7 +951,7 @@ function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion = $condition = ['verb' => ACTIVITY_LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']]; if (Item::exists($condition)) { - logger("pumpio_dolike: found existing like. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']); + Logger::log("pumpio_dolike: found existing like. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']); return; } @@ -984,7 +985,7 @@ function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion = $ret = Item::insert($likedata); - logger("pumpio_dolike: ".$ret." User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']); + Logger::log("pumpio_dolike: ".$ret." User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']); } function pumpio_get_contact($uid, $contact, $no_insert = false) @@ -1432,7 +1433,7 @@ function pumpio_queue_hook(App $a, array &$b) continue; } - logger('pumpio_queue: run'); + Logger::log('pumpio_queue: run'); $r = q("SELECT `user`.* FROM `user` LEFT JOIN `contact` ON `contact`.`uid` = `user`.`uid` WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1", @@ -1444,7 +1445,7 @@ function pumpio_queue_hook(App $a, array &$b) $userdata = $r[0]; - //logger('pumpio_queue: fetching userdata '.print_r($userdata, true)); + //Logger::log('pumpio_queue: fetching userdata '.print_r($userdata, true)); $oauth_token = PConfig::get($userdata['uid'], "pumpio", "oauth_token"); $oauth_token_secret = PConfig::get($userdata['uid'], "pumpio", "oauth_token_secret"); @@ -1460,7 +1461,7 @@ function pumpio_queue_hook(App $a, array &$b) $consumer_key && $consumer_secret) { $username = $user.'@'.$host; - logger('pumpio_queue: able to post for user '.$username); + Logger::log('pumpio_queue: able to post for user '.$username); $z = unserialize($x['content']); @@ -1481,21 +1482,21 @@ function pumpio_queue_hook(App $a, array &$b) if ($success) { $post_id = $user->object->id; - logger('pumpio_queue: send '.$username.': success '.$post_id); + Logger::log('pumpio_queue: send '.$username.': success '.$post_id); if ($post_id && $iscomment) { - logger('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$z['item']); + Logger::log('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$z['item']); Item::update(['extid' => $post_id], ['id' => $z['item']]); } Queue::removeItem($x['id']); } else { - logger('pumpio_queue: send '.$username.': '.$z['url'].' general error: ' . print_r($user, true)); + Logger::log('pumpio_queue: send '.$username.': '.$z['url'].' general error: ' . print_r($user, true)); } } else { - logger("pumpio_queue: Error getting tokens for user ".$userdata['uid']); + Logger::log("pumpio_queue: Error getting tokens for user ".$userdata['uid']); } if (!$success) { - logger('pumpio_queue: delayed'); + Logger::log('pumpio_queue: delayed'); Queue::updateTime($x['id']); } } @@ -1595,7 +1596,7 @@ function pumpio_fetchallcomments(App $a, $uid, $id) $hostname = PConfig::get($uid, 'pumpio', 'host'); $username = PConfig::get($uid, "pumpio", "user"); - logger("pumpio_fetchallcomments: completing comment for user ".$uid." post id ".$id); + Logger::log("pumpio_fetchallcomments: completing comment for user ".$uid." post id ".$id); $own_id = "https://".$hostname."/".$username; @@ -1621,7 +1622,7 @@ function pumpio_fetchallcomments(App $a, $uid, $id) $client->access_token = $otoken; $client->access_token_secret = $osecret; - logger("pumpio_fetchallcomments: fetching comment for user ".$uid." url ".$url); + Logger::log("pumpio_fetchallcomments: fetching comment for user ".$uid." url ".$url); if (pumpio_reachable($url)) { $success = $client->CallAPI($url, 'GET', [], ['FailOnAccessError'=>true], $item); @@ -1684,7 +1685,7 @@ function pumpio_fetchallcomments(App $a, $uid, $id) $post->object = $item; - logger("pumpio_fetchallcomments: posting comment ".$post->object->id." ".print_r($post, true)); + Logger::log("pumpio_fetchallcomments: posting comment ".$post->object->id." ".print_r($post, true)); pumpio_dopost($a, $client, $uid, $self, $post, $own_id, false); } } diff --git a/pumpio/pumpio_sync.php b/pumpio/pumpio_sync.php index a8fa7b3cd..de794ad6a 100644 --- a/pumpio/pumpio_sync.php +++ b/pumpio/pumpio_sync.php @@ -1,5 +1,6 @@ Config::get('system', 'maxloadavg', 50)) { - logger('system: load ' . $load[0] . ' too high. Pumpio sync deferred to next scheduled run.'); + Logger::log('system: load ' . $load[0] . ' too high. Pumpio sync deferred to next scheduled run.'); return; } } diff --git a/randplace/randplace.php b/randplace/randplace.php index 019d6f766..7784d80b4 100644 --- a/randplace/randplace.php +++ b/randplace/randplace.php @@ -20,6 +20,7 @@ */ use Friendica\Core\Addon; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; function randplace_install() { @@ -44,7 +45,7 @@ function randplace_install() { Addon::registerHook('addon_settings', 'addon/randplace/randplace.php', 'randplace_settings'); Addon::registerHook('addon_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post'); - logger("installed randplace"); + Logger::log("installed randplace"); } @@ -63,7 +64,7 @@ function randplace_uninstall() { Addon::unregisterHook('addon_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post'); - logger("removed randplace"); + Logger::log("removed randplace"); } @@ -79,7 +80,7 @@ function randplace_post_hook($a, &$item) { * */ - logger('randplace invoked'); + Logger::log('randplace invoked'); if(! local_user()) /* non-zero if this is a logged in user of this system */ return; diff --git a/securemail/securemail.php b/securemail/securemail.php index d935160e0..e39b88ef2 100644 --- a/securemail/securemail.php +++ b/securemail/securemail.php @@ -10,6 +10,7 @@ use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Util\Emailer; @@ -31,7 +32,7 @@ function securemail_install() { Addon::registerHook('emailer_send_prepare', 'addon/securemail/securemail.php', 'securemail_emailer_send_prepare'); - logger('installed securemail'); + Logger::log('installed securemail'); } function securemail_uninstall() { @@ -40,7 +41,7 @@ function securemail_uninstall() { Addon::unregisterHook('emailer_send_prepare', 'addon/securemail/securemail.php', 'securemail_emailer_send_prepare'); - logger('removed securemail'); + Logger::log('removed securemail'); } /** diff --git a/smileybutton/smileybutton.php b/smileybutton/smileybutton.php index e5aaef9c9..f4db08d97 100644 --- a/smileybutton/smileybutton.php +++ b/smileybutton/smileybutton.php @@ -6,12 +6,13 @@ * Author: Johannes Schwab */ use Friendica\Core\Addon; +use Friendica\Core\Logger; function smileybutton_install() { //Register hooks Addon::registerHook('jot_tool', 'addon/smileybutton/smileybutton.php', 'show_button'); - logger("installed smileybutton"); + Logger::log("installed smileybutton"); } @@ -19,7 +20,7 @@ function smileybutton_uninstall() { //Delet registered hooks Addon::unregisterHook('jot_tool', 'addon/smileybutton/smileybutton.php', 'show_button'); - logger("removed smileybutton"); + Logger::log("removed smileybutton"); } diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 6cdc2372c..81cf7f35e 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -46,6 +46,7 @@ use Friendica\Content\Text\Plaintext; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Database\DBA; @@ -70,7 +71,7 @@ function statusnet_install() Addon::registerHook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron'); Addon::registerHook('prepare_body', 'addon/statusnet/statusnet.php', 'statusnet_prepare_body'); Addon::registerHook('check_item_notification', 'addon/statusnet/statusnet.php', 'statusnet_check_item_notification'); - logger("installed GNU Social"); + Logger::log("installed GNU Social"); } function statusnet_uninstall() @@ -429,7 +430,7 @@ function statusnet_action(App $a, $uid, $pid, $action) $connection = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret); - logger("statusnet_action '" . $action . "' ID: " . $pid, LOGGER_DATA); + Logger::log("statusnet_action '" . $action . "' ID: " . $pid, LOGGER_DATA); switch ($action) { case "delete": @@ -442,7 +443,7 @@ function statusnet_action(App $a, $uid, $pid, $action) $result = $connection->post("favorites/destroy/" . $pid); break; } - logger("statusnet_action '" . $action . "' send, result: " . print_r($result, true), LOGGER_DEBUG); + Logger::log("statusnet_action '" . $action . "' send, result: " . print_r($result, true), LOGGER_DEBUG); } function statusnet_post_hook(App $a, &$b) @@ -459,19 +460,19 @@ function statusnet_post_hook(App $a, &$b) $hostname = preg_replace("=https?://([\w\.]*)/.*=ism", "$1", $api); if ($b['parent'] != $b['id']) { - logger("statusnet_post_hook: parameter " . print_r($b, true), LOGGER_DATA); + Logger::log("statusnet_post_hook: parameter " . print_r($b, true), LOGGER_DATA); // Looking if its a reply to a GNU Social post $hostlength = strlen($hostname) + 2; if ((substr($b["parent-uri"], 0, $hostlength) != $hostname . "::") && (substr($b["extid"], 0, $hostlength) != $hostname . "::") && (substr($b["thr-parent"], 0, $hostlength) != $hostname . "::")) { - logger("statusnet_post_hook: no GNU Social post " . $b["parent"]); + Logger::log("statusnet_post_hook: no GNU Social post " . $b["parent"]); return; } $condition = ['uri' => $b["thr-parent"], 'uid' => $b["uid"]]; $orig_post = Item::selectFirst(['author-link', 'uri'], $condition); if (!DBA::isResult($orig_post)) { - logger("statusnet_post_hook: no parent found " . $b["thr-parent"]); + Logger::log("statusnet_post_hook: no parent found " . $b["thr-parent"]); return; } else { $iscomment = true; @@ -482,12 +483,12 @@ function statusnet_post_hook(App $a, &$b) $nickname = "@[url=" . $orig_post["author-link"] . "]" . $nick . "[/url]"; $nicknameplain = "@" . $nick; - logger("statusnet_post_hook: comparing " . $nickname . " and " . $nicknameplain . " with " . $b["body"], LOGGER_DEBUG); + Logger::log("statusnet_post_hook: comparing " . $nickname . " and " . $nicknameplain . " with " . $b["body"], LOGGER_DEBUG); if ((strpos($b["body"], $nickname) === false) && (strpos($b["body"], $nicknameplain) === false)) { $b["body"] = $nickname . " " . $b["body"]; } - logger("statusnet_post_hook: parent found " . print_r($orig_post, true), LOGGER_DEBUG); + Logger::log("statusnet_post_hook: parent found " . print_r($orig_post, true), LOGGER_DEBUG); } else { $iscomment = false; @@ -508,7 +509,7 @@ function statusnet_post_hook(App $a, &$b) } if ($b['verb'] == ACTIVITY_LIKE) { - logger("statusnet_post_hook: parameter 2 " . substr($b["thr-parent"], $hostlength), LOGGER_DEBUG); + Logger::log("statusnet_post_hook: parameter 2 " . substr($b["thr-parent"], $hostlength), LOGGER_DEBUG); if ($b['deleted']) statusnet_action($a, $b["uid"], substr($b["thr-parent"], $hostlength), "unlike"); else @@ -529,7 +530,7 @@ function statusnet_post_hook(App $a, &$b) return; } - logger('GNU Socialpost invoked'); + Logger::log('GNU Socialpost invoked'); PConfig::load($b['uid'], 'statusnet'); @@ -578,7 +579,7 @@ function statusnet_post_hook(App $a, &$b) if (strlen($msg)) { if ($iscomment) { $postdata["in_reply_to_status_id"] = substr($orig_post["uri"], $hostlength); - logger('statusnet_post send reply ' . print_r($postdata, true), LOGGER_DEBUG); + Logger::log('statusnet_post send reply ' . print_r($postdata, true), LOGGER_DEBUG); } // New code that is able to post pictures @@ -589,7 +590,7 @@ function statusnet_post_hook(App $a, &$b) $cb->setToken($otoken, $osecret); $result = $cb->statuses_update($postdata); //$result = $dent->post('statuses/update', $postdata); - logger('statusnet_post send, result: ' . print_r($result, true) . + Logger::log('statusnet_post send, result: ' . print_r($result, true) . "\nmessage: " . $msg . "\nOriginal post: " . print_r($b, true) . "\nPost Data: " . print_r($postdata, true), LOGGER_DEBUG); if (!empty($result->source)) { @@ -597,9 +598,9 @@ function statusnet_post_hook(App $a, &$b) } if (!empty($result->error)) { - logger('Send to GNU Social failed: "' . $result->error . '"'); + Logger::log('Send to GNU Social failed: "' . $result->error . '"'); } elseif ($iscomment) { - logger('statusnet_post: Update extid ' . $result->id . " for post id " . $b['id']); + Logger::log('statusnet_post: Update extid ' . $result->id . " for post id " . $b['id']); Item::update(['extid' => $hostname . "::" . $result->id, 'body' => $result->text], ['id' => $b['id']]); } } @@ -729,16 +730,16 @@ function statusnet_cron(App $a, $b) if ($last) { $next = $last + ($poll_interval * 60); if ($next > time()) { - logger('statusnet: poll intervall not reached'); + Logger::log('statusnet: poll intervall not reached'); return; } } - logger('statusnet: cron_start'); + Logger::log('statusnet: cron_start'); $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'mirror_posts' AND `v` = '1' ORDER BY RAND() "); if (DBA::isResult($r)) { foreach ($r as $rr) { - logger('statusnet: fetching for user ' . $rr['uid']); + Logger::log('statusnet: fetching for user ' . $rr['uid']); statusnet_fetchtimeline($a, $rr['uid']); } } @@ -756,17 +757,17 @@ function statusnet_cron(App $a, $b) if ($abandon_days != 0) { $user = q("SELECT `login_date` FROM `user` WHERE uid=%d AND `login_date` >= '%s'", $rr['uid'], $abandon_limit); if (!DBA::isResult($user)) { - logger('abandoned account: timeline from user ' . $rr['uid'] . ' will not be imported'); + Logger::log('abandoned account: timeline from user ' . $rr['uid'] . ' will not be imported'); continue; } } - logger('statusnet: importing timeline from user ' . $rr['uid']); + Logger::log('statusnet: importing timeline from user ' . $rr['uid']); statusnet_fetchhometimeline($a, $rr["uid"], $rr["v"]); } } - logger('statusnet: cron_end'); + Logger::log('statusnet: cron_end'); Config::set('statusnet', 'last_poll', time()); } @@ -871,7 +872,7 @@ function statusnet_fetchtimeline(App $a, $uid) //print_r($_REQUEST); if ($_REQUEST["body"] != "") { - logger('statusnet: posting for user ' . $uid); + Logger::log('statusnet: posting for user ' . $uid); item_post($a); } @@ -912,7 +913,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user) } if (DBA::isResult($r) && ($r[0]["readonly"] || $r[0]["blocked"])) { - logger("statusnet_fetch_contact: Contact '" . $r[0]["nick"] . "' is blocked or readonly.", LOGGER_DEBUG); + Logger::log("statusnet_fetch_contact: Contact '" . $r[0]["nick"] . "' is blocked or readonly.", LOGGER_DEBUG); return -1; } @@ -974,7 +975,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user) // check that we have all the photos, this has been known to fail on occasion if ((!$r[0]['photo']) || (!$r[0]['thumb']) || (!$r[0]['micro']) || ($update_photo)) { - logger("statusnet_fetch_contact: Updating contact " . $contact->screen_name, LOGGER_DEBUG); + Logger::log("statusnet_fetch_contact: Updating contact " . $contact->screen_name, LOGGER_DEBUG); $photos = Photo::importProfilePhoto($contact->profile_image_url, $uid, $r[0]['id']); @@ -1060,7 +1061,7 @@ function statusnet_fetchuser(App $a, $uid, $screen_name = "", $user_id = "") function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_existing_contact) { - logger("statusnet_createpost: start", LOGGER_DEBUG); + Logger::log("statusnet_createpost: start", LOGGER_DEBUG); $api = PConfig::get($uid, 'statusnet', 'baseapi'); $hostname = preg_replace("=https?://([\w\.]*)/.*=ism", "$1", $api); @@ -1187,7 +1188,7 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex $postarray["coord"] = $content->coordinates->coordinates[1] . " " . $content->coordinates->coordinates[0]; } - logger("statusnet_createpost: end", LOGGER_DEBUG); + Logger::log("statusnet_createpost: end", LOGGER_DEBUG); return $postarray; } @@ -1206,7 +1207,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1) // "create_user" is deactivated, since currently you cannot add users manually by now $create_user = true; - logger("statusnet_fetchhometimeline: Fetching for user " . $uid, LOGGER_DEBUG); + Logger::log("statusnet_fetchhometimeline: Fetching for user " . $uid, LOGGER_DEBUG); require_once 'include/items.php'; @@ -1221,7 +1222,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1) if (DBA::isResult($r)) { $nick = $r[0]["nick"]; } else { - logger("statusnet_fetchhometimeline: Own GNU Social contact not found for user " . $uid, LOGGER_DEBUG); + Logger::log("statusnet_fetchhometimeline: Own GNU Social contact not found for user " . $uid, LOGGER_DEBUG); return; } @@ -1231,14 +1232,14 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1) if (DBA::isResult($r)) { $self = $r[0]; } else { - logger("statusnet_fetchhometimeline: Own contact not found for user " . $uid, LOGGER_DEBUG); + Logger::log("statusnet_fetchhometimeline: Own contact not found for user " . $uid, LOGGER_DEBUG); return; } $u = q("SELECT * FROM user WHERE uid = %d LIMIT 1", intval($uid)); if (!DBA::isResult($u)) { - logger("statusnet_fetchhometimeline: Own user not found for user " . $uid, LOGGER_DEBUG); + Logger::log("statusnet_fetchhometimeline: Own user not found for user " . $uid, LOGGER_DEBUG); return; } @@ -1269,13 +1270,13 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1) $errormsg = "Unknown error"; } - logger("statusnet_fetchhometimeline: Error fetching home timeline: " . $errormsg, LOGGER_DEBUG); + Logger::log("statusnet_fetchhometimeline: Error fetching home timeline: " . $errormsg, LOGGER_DEBUG); return; } $posts = array_reverse($items); - logger("statusnet_fetchhometimeline: Fetching timeline for user " . $uid . " " . sizeof($posts) . " items", LOGGER_DEBUG); + Logger::log("statusnet_fetchhometimeline: Fetching timeline for user " . $uid . " " . sizeof($posts) . " items", LOGGER_DEBUG); if (count($posts)) { foreach ($posts as $post) { @@ -1303,7 +1304,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1) $item = Item::insert($postarray); $postarray["id"] = $item; - logger('statusnet_fetchhometimeline: User ' . $self["nick"] . ' posted home timeline item ' . $item); + Logger::log('statusnet_fetchhometimeline: User ' . $self["nick"] . ' posted home timeline item ' . $item); } } } @@ -1321,13 +1322,13 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1) $items = $connection->get('statuses/mentions_timeline', $parameters); if (!is_array($items)) { - logger("statusnet_fetchhometimeline: Error fetching mentions: " . print_r($items, true), LOGGER_DEBUG); + Logger::log("statusnet_fetchhometimeline: Error fetching mentions: " . print_r($items, true), LOGGER_DEBUG); return; } $posts = array_reverse($items); - logger("statusnet_fetchhometimeline: Fetching mentions for user " . $uid . " " . sizeof($posts) . " items", LOGGER_DEBUG); + Logger::log("statusnet_fetchhometimeline: Fetching mentions for user " . $uid . " " . sizeof($posts) . " items", LOGGER_DEBUG); if (count($posts)) { foreach ($posts as $post) { @@ -1353,7 +1354,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1) $item = Item::insert($postarray); - logger('statusnet_fetchhometimeline: User ' . $self["nick"] . ' posted mention timeline item ' . $item); + Logger::log('statusnet_fetchhometimeline: User ' . $self["nick"] . ' posted mention timeline item ' . $item); } } } @@ -1388,7 +1389,7 @@ function statusnet_complete_conversation(App $a, $uid, $self, $create_user, $nic $item = Item::insert($postarray); $postarray["id"] = $item; - logger('statusnet_complete_conversation: User ' . $self["nick"] . ' posted home timeline item ' . $item); + Logger::log('statusnet_complete_conversation: User ' . $self["nick"] . ' posted home timeline item ' . $item); } } } @@ -1411,15 +1412,15 @@ function statusnet_convertmsg(App $a, $body, $no_tags = false) foreach ($matches AS $match) { $search = "[url=" . $match[1] . "]" . $match[2] . "[/url]"; - logger("statusnet_convertmsg: expanding url " . $match[1], LOGGER_DEBUG); + Logger::log("statusnet_convertmsg: expanding url " . $match[1], LOGGER_DEBUG); $expanded_url = Network::finalUrl($match[1]); - logger("statusnet_convertmsg: fetching data for " . $expanded_url, LOGGER_DEBUG); + Logger::log("statusnet_convertmsg: fetching data for " . $expanded_url, LOGGER_DEBUG); $oembed_data = OEmbed::fetchURL($expanded_url, true); - logger("statusnet_convertmsg: fetching data: done", LOGGER_DEBUG); + Logger::log("statusnet_convertmsg: fetching data: done", LOGGER_DEBUG); if ($type == "") { $type = $oembed_data->type; @@ -1581,13 +1582,13 @@ function statusnet_is_retweet(App $a, $uid, $body) return false; } - logger('statusnet_is_retweet: Retweeting id ' . $id . ' for user ' . $uid, LOGGER_DEBUG); + Logger::log('statusnet_is_retweet: Retweeting id ' . $id . ' for user ' . $uid, LOGGER_DEBUG); $connection = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret); $result = $connection->post('statuses/retweet/' . $id); - logger('statusnet_is_retweet: result ' . print_r($result, true), LOGGER_DEBUG); + Logger::log('statusnet_is_retweet: result ' . print_r($result, true), LOGGER_DEBUG); return isset($result->id); } diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php index 5862958de..7d232a6a6 100644 --- a/tumblr/tumblr.php +++ b/tumblr/tumblr.php @@ -14,6 +14,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Database\DBA; @@ -458,11 +459,11 @@ function tumblr_send(App $a, array &$b) { //print_r($params); if ($ret_code == 201) { - logger('tumblr_send: success'); + Logger::log('tumblr_send: success'); } elseif ($ret_code == 403) { - logger('tumblr_send: authentication failure'); + Logger::log('tumblr_send: authentication failure'); } else { - logger('tumblr_send: general error: ' . print_r($x,true)); + Logger::log('tumblr_send: general error: ' . print_r($x,true)); } } } diff --git a/twitter/twitter.php b/twitter/twitter.php index 597278ca2..2a04da9f4 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -69,6 +69,7 @@ use Friendica\Content\Text\Plaintext; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Core\Worker; @@ -109,7 +110,7 @@ function twitter_install() Addon::registerHook('expire' , __FILE__, 'twitter_expire'); Addon::registerHook('prepare_body' , __FILE__, 'twitter_prepare_body'); Addon::registerHook('check_item_notification', __FILE__, 'twitter_check_item_notification'); - logger("installed twitter"); + Logger::log("installed twitter"); } function twitter_uninstall() @@ -154,7 +155,7 @@ function twitter_check_item_notification(App $a, array &$notification_data) function twitter_follow(App $a, array &$contact) { - logger("twitter_follow: Check if contact is twitter contact. " . $contact["url"], LOGGER_DEBUG); + Logger::log("twitter_follow: Check if contact is twitter contact. " . $contact["url"], LOGGER_DEBUG); if (!strstr($contact["url"], "://twitter.com") && !strstr($contact["url"], "@twitter.com")) { return; @@ -235,7 +236,7 @@ function twitter_settings_post(App $a) } else { if (isset($_POST['twitter-pin'])) { // if the user supplied us with a PIN from Twitter, let the magic of OAuth happen - logger('got a Twitter PIN'); + Logger::log('got a Twitter PIN'); $ckey = Config::get('twitter', 'consumerkey'); $csecret = Config::get('twitter', 'consumersecret'); // the token and secret for which the PIN was generated were hidden in the settings @@ -427,7 +428,7 @@ function twitter_action(App $a, $uid, $pid, $action) $post = ['id' => $pid]; - logger("twitter_action '" . $action . "' ID: " . $pid . " data: " . print_r($post, true), LOGGER_DATA); + Logger::log("twitter_action '" . $action . "' ID: " . $pid . " data: " . print_r($post, true), LOGGER_DATA); switch ($action) { case "delete": @@ -441,10 +442,10 @@ function twitter_action(App $a, $uid, $pid, $action) $result = $connection->post('favorites/destroy', $post); break; default: - logger('Unhandled action ' . $action, LOGGER_DEBUG); + Logger::log('Unhandled action ' . $action, LOGGER_DEBUG); $result = []; } - logger("twitter_action '" . $action . "' send, result: " . print_r($result, true), LOGGER_DEBUG); + Logger::log("twitter_action '" . $action . "' send, result: " . print_r($result, true), LOGGER_DEBUG); } function twitter_post_hook(App $a, array &$b) @@ -456,21 +457,21 @@ function twitter_post_hook(App $a, array &$b) } if ($b['parent'] != $b['id']) { - logger("twitter_post_hook: parameter " . print_r($b, true), LOGGER_DATA); + Logger::log("twitter_post_hook: parameter " . print_r($b, true), LOGGER_DATA); // Looking if its a reply to a twitter post if ((substr($b["parent-uri"], 0, 9) != "twitter::") && (substr($b["extid"], 0, 9) != "twitter::") && (substr($b["thr-parent"], 0, 9) != "twitter::")) { - logger("twitter_post_hook: no twitter post " . $b["parent"]); + Logger::log("twitter_post_hook: no twitter post " . $b["parent"]); return; } $condition = ['uri' => $b["thr-parent"], 'uid' => $b["uid"]]; $orig_post = Item::selectFirst([], $condition); if (!DBA::isResult($orig_post)) { - logger("twitter_post_hook: no parent found " . $b["thr-parent"]); + Logger::log("twitter_post_hook: no parent found " . $b["thr-parent"]); return; } else { $iscomment = true; @@ -481,12 +482,12 @@ function twitter_post_hook(App $a, array &$b) $nickname = "@[url=" . $orig_post["author-link"] . "]" . $nicknameplain . "[/url]"; $nicknameplain = "@" . $nicknameplain; - logger("twitter_post_hook: comparing " . $nickname . " and " . $nicknameplain . " with " . $b["body"], LOGGER_DEBUG); + Logger::log("twitter_post_hook: comparing " . $nickname . " and " . $nicknameplain . " with " . $b["body"], LOGGER_DEBUG); if ((strpos($b["body"], $nickname) === false) && (strpos($b["body"], $nicknameplain) === false)) { $b["body"] = $nickname . " " . $b["body"]; } - logger("twitter_post_hook: parent found " . print_r($orig_post, true), LOGGER_DATA); + Logger::log("twitter_post_hook: parent found " . print_r($orig_post, true), LOGGER_DATA); } else { $iscomment = false; @@ -507,7 +508,7 @@ function twitter_post_hook(App $a, array &$b) } if ($b['verb'] == ACTIVITY_LIKE) { - logger("twitter_post_hook: parameter 2 " . substr($b["thr-parent"], 9), LOGGER_DEBUG); + Logger::log("twitter_post_hook: parameter 2 " . substr($b["thr-parent"], 9), LOGGER_DEBUG); if ($b['deleted']) { twitter_action($a, $b["uid"], substr($b["thr-parent"], 9), "unlike"); } else { @@ -530,7 +531,7 @@ function twitter_post_hook(App $a, array &$b) return; } - logger('twitter post invoked'); + Logger::log('twitter post invoked'); PConfig::load($b['uid'], 'twitter'); @@ -540,7 +541,7 @@ function twitter_post_hook(App $a, array &$b) $osecret = PConfig::get($b['uid'], 'twitter', 'oauthsecret'); if ($ckey && $csecret && $otoken && $osecret) { - logger('twitter: we have customer key and oauth stuff, going to send.', LOGGER_DEBUG); + Logger::log('twitter: we have customer key and oauth stuff, going to send.', LOGGER_DEBUG); // If it's a repeated message from twitter then do a native retweet and exit if (twitter_is_retweet($a, $b['uid'], $b['body'])) { @@ -608,7 +609,7 @@ function twitter_post_hook(App $a, array &$b) throw new Exception('Failed upload of ' . $image); } } catch (Exception $e) { - logger('Exception when trying to send to Twitter: ' . $e->getMessage()); + Logger::log('Exception when trying to send to Twitter: ' . $e->getMessage()); // Workaround: Remove the picture link so that the post can be reposted without it // When there is another url already added, a second url would be superfluous. @@ -628,14 +629,14 @@ function twitter_post_hook(App $a, array &$b) $url = 'statuses/update'; $result = $connection->post($url, $post); - logger('twitter_post send, result: ' . print_r($result, true), LOGGER_DEBUG); + Logger::log('twitter_post send, result: ' . print_r($result, true), LOGGER_DEBUG); if (!empty($result->source)) { Config::set("twitter", "application_name", strip_tags($result->source)); } if (!empty($result->errors)) { - logger('Send to Twitter failed: "' . print_r($result->errors, true) . '"'); + Logger::log('Send to Twitter failed: "' . print_r($result->errors, true) . '"'); $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", intval($b['uid'])); if (DBA::isResult($r)) { @@ -647,7 +648,7 @@ function twitter_post_hook(App $a, array &$b) Queue::add($a->contact, Protocol::TWITTER, $s); notice(L10n::t('Twitter post failed. Queued for retry.') . EOL); } elseif ($iscomment) { - logger('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']); + Logger::log('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']); Item::update(['extid' => "twitter::" . $result->id_str], ['id' => $b['id']]); } } @@ -686,16 +687,16 @@ function twitter_cron(App $a) if ($last) { $next = $last + ($poll_interval * 60); if ($next > time()) { - logger('twitter: poll intervall not reached'); + Logger::log('twitter: poll intervall not reached'); return; } } - logger('twitter: cron_start'); + Logger::log('twitter: cron_start'); $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'mirror_posts' AND `v` = '1'"); if (DBA::isResult($r)) { foreach ($r as $rr) { - logger('twitter: fetching for user ' . $rr['uid']); + Logger::log('twitter: fetching for user ' . $rr['uid']); Worker::add(PRIORITY_MEDIUM, "addon/twitter/twitter_sync.php", 1, (int) $rr['uid']); } } @@ -713,12 +714,12 @@ function twitter_cron(App $a) if ($abandon_days != 0) { $user = q("SELECT `login_date` FROM `user` WHERE uid=%d AND `login_date` >= '%s'", $rr['uid'], $abandon_limit); if (!DBA::isResult($user)) { - logger('abandoned account: timeline from user ' . $rr['uid'] . ' will not be imported'); + Logger::log('abandoned account: timeline from user ' . $rr['uid'] . ' will not be imported'); continue; } } - logger('twitter: importing timeline from user ' . $rr['uid']); + Logger::log('twitter: importing timeline from user ' . $rr['uid']); Worker::add(PRIORITY_MEDIUM, "addon/twitter/twitter_sync.php", 2, (int) $rr['uid']); /* // To-Do @@ -737,7 +738,7 @@ function twitter_cron(App $a) } } - logger('twitter: cron_end'); + Logger::log('twitter: cron_end'); Config::set('twitter', 'last_poll', time()); } @@ -758,17 +759,17 @@ function twitter_expire(App $a) require_once "include/items.php"; - logger('twitter_expire: expire_start'); + Logger::log('twitter_expire: expire_start'); $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'import' AND `v` = '1' ORDER BY RAND()"); if (DBA::isResult($r)) { foreach ($r as $rr) { - logger('twitter_expire: user ' . $rr['uid']); + Logger::log('twitter_expire: user ' . $rr['uid']); Item::expire($rr['uid'], $days, Protocol::TWITTER, true); } } - logger('twitter_expire: expire_end'); + Logger::log('twitter_expire: expire_end'); } function twitter_prepare_body(App $a, array &$b) @@ -903,18 +904,18 @@ function twitter_fetchtimeline(App $a, $uid) try { $items = $connection->get('statuses/user_timeline', $parameters); } catch (TwitterOAuthException $e) { - logger('Error fetching timeline for user ' . $uid . ': ' . $e->getMessage()); + Logger::log('Error fetching timeline for user ' . $uid . ': ' . $e->getMessage()); return; } if (!is_array($items)) { - logger('No items for user ' . $uid, LOGGER_INFO); + Logger::log('No items for user ' . $uid, LOGGER_INFO); return; } $posts = array_reverse($items); - logger('Starting from ID ' . $lastid . ' for user ' . $uid, LOGGER_DEBUG); + Logger::log('Starting from ID ' . $lastid . ' for user ' . $uid, LOGGER_DEBUG); if (count($posts)) { foreach ($posts as $post) { @@ -931,7 +932,7 @@ function twitter_fetchtimeline(App $a, $uid) $_SESSION["authenticated"] = true; $_SESSION["uid"] = $uid; - logger('Preparing Twitter ID ' . $post->id_str . ' for user ' . $uid, LOGGER_DEBUG); + Logger::log('Preparing Twitter ID ' . $post->id_str . ' for user ' . $uid, LOGGER_DEBUG); $_REQUEST = twitter_do_mirrorpost($a, $uid, $post); @@ -939,14 +940,14 @@ function twitter_fetchtimeline(App $a, $uid) continue; } - logger('Posting Twitter ID ' . $post->id_str . ' for user ' . $uid); + Logger::log('Posting Twitter ID ' . $post->id_str . ' for user ' . $uid); item_post($a); } } } PConfig::set($uid, 'twitter', 'lastid', $lastid); - logger('Last ID for user ' . $uid . ' is now ' . $lastid, LOGGER_DEBUG); + Logger::log('Last ID for user ' . $uid . ' is now ' . $lastid, LOGGER_DEBUG); } function twitter_queue_hook(App $a) @@ -963,7 +964,7 @@ function twitter_queue_hook(App $a) continue; } - logger('twitter_queue: run'); + Logger::log('twitter_queue: run'); $r = q("SELECT `user`.* FROM `user` LEFT JOIN `contact` on `contact`.`uid` = `user`.`uid` WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1", @@ -983,27 +984,27 @@ function twitter_queue_hook(App $a) $success = false; if ($ckey && $csecret && $otoken && $osecret) { - logger('twitter_queue: able to post'); + Logger::log('twitter_queue: able to post'); $z = unserialize($x['content']); $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret); $result = $connection->post($z['url'], $z['post']); - logger('twitter_queue: post result: ' . print_r($result, true), LOGGER_DEBUG); + Logger::log('twitter_queue: post result: ' . print_r($result, true), LOGGER_DEBUG); if ($result->errors) { - logger('twitter_queue: Send to Twitter failed: "' . print_r($result->errors, true) . '"'); + Logger::log('twitter_queue: Send to Twitter failed: "' . print_r($result->errors, true) . '"'); } else { $success = true; Queue::removeItem($x['id']); } } else { - logger("twitter_queue: Error getting tokens for user " . $user['uid']); + Logger::log("twitter_queue: Error getting tokens for user " . $user['uid']); } if (!$success) { - logger('twitter_queue: delayed'); + Logger::log('twitter_queue: delayed'); Queue::updateTime($x['id']); } } @@ -1077,7 +1078,7 @@ function twitter_fetch_contact($uid, $data, $create_user) Contact::updateAvatar($avatar, $uid, $contact_id); } else { if ($contact["readonly"] || $contact["blocked"]) { - logger("twitter_fetch_contact: Contact '" . $contact["nick"] . "' is blocked or readonly.", LOGGER_DEBUG); + Logger::log("twitter_fetch_contact: Contact '" . $contact["nick"] . "' is blocked or readonly.", LOGGER_DEBUG); return -1; } @@ -1088,7 +1089,7 @@ function twitter_fetch_contact($uid, $data, $create_user) // check that we have all the photos, this has been known to fail on occasion if (empty($contact['photo']) || empty($contact['thumb']) || empty($contact['micro']) || $update_photo) { - logger("twitter_fetch_contact: Updating contact " . $data->screen_name, LOGGER_DEBUG); + Logger::log("twitter_fetch_contact: Updating contact " . $data->screen_name, LOGGER_DEBUG); Contact::updateAvatar($avatar, $uid, $contact['id']); @@ -1133,7 +1134,7 @@ function twitter_fetchuser(App $a, $uid, $screen_name = "", $user_id = "") try { $user = $connection->get('users/show', $parameters); } catch (TwitterOAuthException $e) { - logger('twitter_fetchuser: Error fetching user ' . $uid . ': ' . $e->getMessage()); + Logger::log('twitter_fetchuser: Error fetching user ' . $uid . ': ' . $e->getMessage()); return; } @@ -1387,7 +1388,7 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl // Don't import our own comments if (Item::exists(['extid' => $postarray['uri'], 'uid' => $uid])) { - logger("Item with extid " . $postarray['uri'] . " found.", LOGGER_DEBUG); + Logger::log("Item with extid " . $postarray['uri'] . " found.", LOGGER_DEBUG); return []; } @@ -1427,7 +1428,7 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl $postarray['owner-link'] = $r[0]["url"]; $postarray['owner-avatar'] = $r[0]["photo"]; } else { - logger("No self contact for user " . $uid, LOGGER_DEBUG); + Logger::log("No self contact for user " . $uid, LOGGER_DEBUG); return []; } } @@ -1449,7 +1450,7 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl if (($contactid == 0) && !$only_existing_contact) { $contactid = $self['id']; } elseif ($contactid <= 0) { - logger("Contact ID is zero or less than zero.", LOGGER_DEBUG); + Logger::log("Contact ID is zero or less than zero.", LOGGER_DEBUG); return []; } @@ -1546,7 +1547,7 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl function twitter_fetchparentposts(App $a, $uid, $post, TwitterOAuth $connection, array $self) { - logger("twitter_fetchparentposts: Fetching for user " . $uid . " and post " . $post->id_str, LOGGER_DEBUG); + Logger::log("twitter_fetchparentposts: Fetching for user " . $uid . " and post " . $post->id_str, LOGGER_DEBUG); $posts = []; @@ -1556,17 +1557,17 @@ function twitter_fetchparentposts(App $a, $uid, $post, TwitterOAuth $connection, try { $post = $connection->get('statuses/show', $parameters); } catch (TwitterOAuthException $e) { - logger('twitter_fetchparentposts: Error fetching for user ' . $uid . ' and post ' . $post->id_str . ': ' . $e->getMessage()); + Logger::log('twitter_fetchparentposts: Error fetching for user ' . $uid . ' and post ' . $post->id_str . ': ' . $e->getMessage()); break; } if (empty($post)) { - logger("twitter_fetchparentposts: Can't fetch post " . $parameters->id, LOGGER_DEBUG); + Logger::log("twitter_fetchparentposts: Can't fetch post " . $parameters->id, LOGGER_DEBUG); break; } if (empty($post->id_str)) { - logger("twitter_fetchparentposts: This is not a post " . json_encode($post), LOGGER_DEBUG); + Logger::log("twitter_fetchparentposts: This is not a post " . json_encode($post), LOGGER_DEBUG); break; } @@ -1577,7 +1578,7 @@ function twitter_fetchparentposts(App $a, $uid, $post, TwitterOAuth $connection, $posts[] = $post; } - logger("twitter_fetchparentposts: Fetching " . count($posts) . " parents", LOGGER_DEBUG); + Logger::log("twitter_fetchparentposts: Fetching " . count($posts) . " parents", LOGGER_DEBUG); $posts = array_reverse($posts); @@ -1593,7 +1594,7 @@ function twitter_fetchparentposts(App $a, $uid, $post, TwitterOAuth $connection, $postarray["id"] = $item; - logger('twitter_fetchparentpost: User ' . $self["nick"] . ' posted parent timeline item ' . $item); + Logger::log('twitter_fetchparentpost: User ' . $self["nick"] . ' posted parent timeline item ' . $item); } } } @@ -1607,7 +1608,7 @@ function twitter_fetchhometimeline(App $a, $uid) $create_user = PConfig::get($uid, 'twitter', 'create_user'); $mirror_posts = PConfig::get($uid, 'twitter', 'mirror_posts'); - logger("Fetching timeline for user " . $uid, LOGGER_DEBUG); + Logger::log("Fetching timeline for user " . $uid, LOGGER_DEBUG); $application_name = Config::get('twitter', 'application_name'); @@ -1622,7 +1623,7 @@ function twitter_fetchhometimeline(App $a, $uid) try { $own_contact = twitter_fetch_own_contact($a, $uid); } catch (TwitterOAuthException $e) { - logger('Error fetching own contact for user ' . $uid . ': ' . $e->getMessage()); + Logger::log('Error fetching own contact for user ' . $uid . ': ' . $e->getMessage()); return; } @@ -1633,13 +1634,13 @@ function twitter_fetchhometimeline(App $a, $uid) if (DBA::isResult($r)) { $own_id = $r[0]["nick"]; } else { - logger("Own twitter contact not found for user " . $uid); + Logger::log("Own twitter contact not found for user " . $uid); return; } $self = User::getOwnerDataById($uid); if ($self === false) { - logger("Own contact not found for user " . $uid); + Logger::log("Own contact not found for user " . $uid); return; } @@ -1657,23 +1658,23 @@ function twitter_fetchhometimeline(App $a, $uid) try { $items = $connection->get('statuses/home_timeline', $parameters); } catch (TwitterOAuthException $e) { - logger('Error fetching home timeline for user ' . $uid . ': ' . $e->getMessage()); + Logger::log('Error fetching home timeline for user ' . $uid . ': ' . $e->getMessage()); return; } if (!is_array($items)) { - logger('No array while fetching home timeline for user ' . $uid . ': ' . print_r($items, true)); + Logger::log('No array while fetching home timeline for user ' . $uid . ': ' . print_r($items, true)); return; } if (empty($items)) { - logger('No new timeline content for user ' . $uid, LOGGER_INFO); + Logger::log('No new timeline content for user ' . $uid, LOGGER_INFO); return; } $posts = array_reverse($items); - logger('Fetching timeline from ID ' . $lastid . ' for user ' . $uid . ' ' . sizeof($posts) . ' items', LOGGER_DEBUG); + Logger::log('Fetching timeline from ID ' . $lastid . ' for user ' . $uid . ' ' . sizeof($posts) . ' items', LOGGER_DEBUG); if (count($posts)) { foreach ($posts as $post) { @@ -1687,12 +1688,12 @@ function twitter_fetchhometimeline(App $a, $uid) } if (stristr($post->source, $application_name) && $post->user->screen_name == $own_id) { - logger("Skip previously sent post", LOGGER_DEBUG); + Logger::log("Skip previously sent post", LOGGER_DEBUG); continue; } if ($mirror_posts && $post->user->screen_name == $own_id && $post->in_reply_to_status_id_str == "") { - logger("Skip post that will be mirrored", LOGGER_DEBUG); + Logger::log("Skip post that will be mirrored", LOGGER_DEBUG); continue; } @@ -1700,12 +1701,12 @@ function twitter_fetchhometimeline(App $a, $uid) twitter_fetchparentposts($a, $uid, $post, $connection, $self); } - logger('Preparing post ' . $post->id_str . ' for user ' . $uid, LOGGER_DEBUG); + Logger::log('Preparing post ' . $post->id_str . ' for user ' . $uid, LOGGER_DEBUG); $postarray = twitter_createpost($a, $uid, $post, $self, $create_user, true, false); if (empty($postarray['body']) || trim($postarray['body']) == "") { - logger('Empty body for post ' . $post->id_str . ' and user ' . $uid, LOGGER_DEBUG); + Logger::log('Empty body for post ' . $post->id_str . ' and user ' . $uid, LOGGER_DEBUG); continue; } @@ -1721,12 +1722,12 @@ function twitter_fetchhometimeline(App $a, $uid) $item = Item::insert($postarray, false, $notify); $postarray["id"] = $item; - logger('User ' . $uid . ' posted home timeline item ' . $item); + Logger::log('User ' . $uid . ' posted home timeline item ' . $item); } } PConfig::set($uid, 'twitter', 'lasthometimelineid', $lastid); - logger('Last timeline ID for user ' . $uid . ' is now ' . $lastid, LOGGER_DEBUG); + Logger::log('Last timeline ID for user ' . $uid . ' is now ' . $lastid, LOGGER_DEBUG); // Fetching mentions $lastid = PConfig::get($uid, 'twitter', 'lastmentionid'); @@ -1740,18 +1741,18 @@ function twitter_fetchhometimeline(App $a, $uid) try { $items = $connection->get('statuses/mentions_timeline', $parameters); } catch (TwitterOAuthException $e) { - logger('Error fetching mentions: ' . $e->getMessage()); + Logger::log('Error fetching mentions: ' . $e->getMessage()); return; } if (!is_array($items)) { - logger("Error fetching mentions: " . print_r($items, true), LOGGER_DEBUG); + Logger::log("Error fetching mentions: " . print_r($items, true), LOGGER_DEBUG); return; } $posts = array_reverse($items); - logger("Fetching mentions for user " . $uid . " " . sizeof($posts) . " items", LOGGER_DEBUG); + Logger::log("Fetching mentions for user " . $uid . " " . sizeof($posts) . " items", LOGGER_DEBUG); if (count($posts)) { foreach ($posts as $post) { @@ -1775,13 +1776,13 @@ function twitter_fetchhometimeline(App $a, $uid) $item = Item::insert($postarray); - logger('User ' . $uid . ' posted mention timeline item ' . $item); + Logger::log('User ' . $uid . ' posted mention timeline item ' . $item); } } PConfig::set($uid, 'twitter', 'lastmentionid', $lastid); - logger('Last mentions ID for user ' . $uid . ' is now ' . $lastid, LOGGER_DEBUG); + Logger::log('Last mentions ID for user ' . $uid . ' is now ' . $lastid, LOGGER_DEBUG); } function twitter_fetch_own_contact(App $a, $uid) @@ -1856,7 +1857,7 @@ function twitter_is_retweet(App $a, $uid, $body) return false; } - logger('twitter_is_retweet: Retweeting id ' . $id . ' for user ' . $uid, LOGGER_DEBUG); + Logger::log('twitter_is_retweet: Retweeting id ' . $id . ' for user ' . $uid, LOGGER_DEBUG); $ckey = Config::get('twitter', 'consumerkey'); $csecret = Config::get('twitter', 'consumersecret'); @@ -1866,7 +1867,7 @@ function twitter_is_retweet(App $a, $uid, $body) $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret); $result = $connection->post('statuses/retweet/' . $id); - logger('twitter_is_retweet: result ' . print_r($result, true), LOGGER_DEBUG); + Logger::log('twitter_is_retweet: result ' . print_r($result, true), LOGGER_DEBUG); return !isset($result->errors); } diff --git a/twitter/twitter_sync.php b/twitter/twitter_sync.php index 60924acde..b2c655e7c 100644 --- a/twitter/twitter_sync.php +++ b/twitter/twitter_sync.php @@ -1,6 +1,7 @@ Config::get('system', 'maxloadavg', 50)) { - logger('system: load ' . $load[0] . ' too high. Twitter sync deferred to next scheduled run.'); + Logger::log('system: load ' . $load[0] . ' too high. Twitter sync deferred to next scheduled run.'); return; } } diff --git a/widgets/widgets.php b/widgets/widgets.php index 5cb8a2797..8d7cf3ae5 100644 --- a/widgets/widgets.php +++ b/widgets/widgets.php @@ -9,13 +9,14 @@ use Friendica\Core\Addon; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Database\DBA; function widgets_install() { Addon::registerHook('addon_settings', 'addon/widgets/widgets.php', 'widgets_settings'); Addon::registerHook('addon_settings_post', 'addon/widgets/widgets.php', 'widgets_settings_post'); - logger("installed widgets"); + Logger::log("installed widgets"); } function widgets_uninstall() { diff --git a/windowsphonepush/windowsphonepush.php b/windowsphonepush/windowsphonepush.php index 38ab60b3b..b6e455fba 100644 --- a/windowsphonepush/windowsphonepush.php +++ b/windowsphonepush/windowsphonepush.php @@ -32,6 +32,7 @@ use Friendica\Content\Text\HTML; use Friendica\Core\Addon; use Friendica\Core\Authentication; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Database\DBA; use Friendica\Model\Item; @@ -53,7 +54,7 @@ function windowsphonepush_install() Addon::registerHook('addon_settings', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings'); Addon::registerHook('addon_settings_post', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings_post'); - logger("installed windowsphonepush"); + Logger::log("installed windowsphonepush"); } function windowsphonepush_uninstall() @@ -65,7 +66,7 @@ function windowsphonepush_uninstall() Addon::unregisterHook('addon_settings', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings'); Addon::unregisterHook('addon_settings_post', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings_post'); - logger("removed windowsphonepush"); + Logger::log("removed windowsphonepush"); } /* declare the windowsphonepush function so that /windowsphonepush url requests will land here */ @@ -160,7 +161,7 @@ function windowsphonepush_cron() // by app if user has switched the server setting in app - sending blank not possible as this would return an update error) if (( $device_url == "" ) || ( $device_url == "NA" )) { // no Device-URL for the user availabe, but addon is enabled --> write info to Logger - logger("WARN: windowsphonepush is enable for user " . $rr['uid'] . ", but no Device-URL is specified for the user."); + Logger::log("WARN: windowsphonepush is enable for user " . $rr['uid'] . ", but no Device-URL is specified for the user."); } else { // retrieve the number of unseen items and the id of the latest one (if there are more than // one new entries since last poller run, only the latest one will be pushed) @@ -177,11 +178,11 @@ function windowsphonepush_cron() break; case "QueueFull": // maximum of 30 messages reached, server rejects any further push notification until device reconnects - logger("INFO: Device-URL '" . $device_url . "' returns a QueueFull."); + Logger::log("INFO: Device-URL '" . $device_url . "' returns a QueueFull."); break; case "Suppressed": // notification received and dropped as something in app was not enabled - logger("WARN. Device-URL '" . $device_url . "' returns a Suppressed. Unexpected error in Mobile App?"); + Logger::log("WARN. Device-URL '" . $device_url . "' returns a Suppressed. Unexpected error in Mobile App?"); break; case "Dropped": // mostly combines with Expired, in that case Device-URL will be deleted from pconfig (function send_push) @@ -189,7 +190,7 @@ function windowsphonepush_cron() default: // error, mostly called by "" which means that the url (not "" which has been checked) // didn't not received Microsoft Notification Server -> wrong url - logger("ERROR: specified Device-URL '" . $device_url . "' didn't produced any response."); + Logger::log("ERROR: specified Device-URL '" . $device_url . "' didn't produced any response."); } // additionally user receives the text of the newest item (function checks against last successfully pushed item) @@ -306,7 +307,7 @@ function send_push($device_url, $headers, $msg) $subscriptionStatus = get_header_value($output, 'X-SubscriptionStatus'); if ($subscriptionStatus == "Expired") { PConfig::set(local_user(), 'windowsphonepush', 'device_url', ""); - logger("ERROR: the stored Device-URL " . $device_url . "returned an 'Expired' error, it has been deleted now."); + Logger::log("ERROR: the stored Device-URL " . $device_url . "returned an 'Expired' error, it has been deleted now."); } // the notification status shall be returned to windowsphonepush_cron (will @@ -407,7 +408,7 @@ function windowsphonepush_updatesettings() // check if sent url is empty - don't save and send return code to app $device_url = $_POST['deviceurl']; if ($device_url == "") { - logger("ERROR: no valid Device-URL specified - client transferred '" . $device_url . "'"); + Logger::log("ERROR: no valid Device-URL specified - client transferred '" . $device_url . "'"); return "No valid Device-URL specified"; } @@ -422,13 +423,13 @@ function windowsphonepush_updatesettings() if (count($r)) { foreach ($r as $rr) { PConfig::set($rr['uid'], 'windowsphonepush', 'device_url', ''); - logger("WARN: the sent URL was already registered with user '" . $rr['uid'] . "'. Deleted for this user as we expect to be correct now for user '" . local_user() . "'."); + Logger::log("WARN: the sent URL was already registered with user '" . $rr['uid'] . "'. Deleted for this user as we expect to be correct now for user '" . local_user() . "'."); } } PConfig::set(local_user(), 'windowsphonepush', 'device_url', $device_url); // output the successfull update of the device URL to the logger for error analysis if necessary - logger("INFO: Device-URL for user '" . local_user() . "' has been updated with '" . $device_url . "'"); + Logger::log("INFO: Device-URL for user '" . local_user() . "' has been updated with '" . $device_url . "'"); return "Device-URL updated successfully!"; } @@ -455,7 +456,7 @@ function windowsphonepush_updatecounterunseen() function windowsphonepush_login(App $a) { if (!isset($_SERVER['PHP_AUTH_USER'])) { - logger('API_login: ' . print_r($_SERVER, true), LOGGER_DEBUG); + Logger::log('API_login: ' . print_r($_SERVER, true), LOGGER_DEBUG); header('WWW-Authenticate: Basic realm="Friendica"'); header('HTTP/1.0 401 Unauthorized'); die('This api requires login'); @@ -466,7 +467,7 @@ function windowsphonepush_login(App $a) if ($user_id) { $record = DBA::selectFirst('user', [], ['uid' => $user_id]); } else { - logger('API_login failure: ' . print_r($_SERVER, true), LOGGER_DEBUG); + Logger::log('API_login failure: ' . print_r($_SERVER, true), LOGGER_DEBUG); header('WWW-Authenticate: Basic realm="Friendica"'); header('HTTP/1.0 401 Unauthorized'); die('This api requires login'); diff --git a/wppost/wppost.php b/wppost/wppost.php index 76d928a2c..dbad6f97f 100644 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -10,6 +10,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Content\Text\HTML; use Friendica\Core\Addon; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Database\DBA; use Friendica\Util\Network; @@ -312,11 +313,11 @@ function wppost_send(&$a,&$b) { EOT; - logger('wppost: data: ' . $xml, LOGGER_DATA); + Logger::log('wppost: data: ' . $xml, LOGGER_DATA); if ($wp_blog !== 'test') { $x = Network::post($wp_blog, $xml)->getBody(); } - logger('posted to wordpress: ' . (($x) ? $x : ''), LOGGER_DEBUG); + Logger::log('posted to wordpress: ' . (($x) ? $x : ''), LOGGER_DEBUG); } }