Merge pull request #1194 from annando/logger

"log" is replaced with the corresponding logging functions
pull/1195/head
Tobias Diekershoff 2021-10-21 10:41:45 +02:00 committed by GitHub
commit abf06edc90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 72 additions and 72 deletions

View File

@ -64,7 +64,7 @@ function advancedcontentfilter_install(App $a)
Hook::add('dbstructure_definition' , __FILE__, 'advancedcontentfilter_dbstructure_definition');
DBStructure::performUpdate();
Logger::log("installed advancedcontentfilter");
Logger::notice("installed advancedcontentfilter");
}
/*

View File

@ -75,7 +75,7 @@ function blackout_redirect ($a, $b) {
$date2 = 0;
}
if (( $date1 <= $now ) && ( $now <= $date2 )) {
Logger::log('redirecting user to blackout page');
Logger::notice('redirecting user to blackout page');
System::externalRedirect($myurl);
}
}

View File

@ -205,12 +205,12 @@ function blogger_send(App $a, array &$b)
EOT;
Logger::log('blogger: data: ' . $xml, Logger::DATA);
Logger::debug('blogger: data: ' . $xml);
if ($bl_blog !== 'test') {
$x = DI::httpClient()->post($bl_blog, $xml)->getBody();
}
Logger::log('posted to blogger: ' . (($x) ? $x : ''), Logger::DEBUG);
Logger::info('posted to blogger: ' . (($x) ? $x : ''));
}
}

View File

@ -103,7 +103,7 @@ function buffer_connect(App $a)
if (!$buffer->ok) {
$o = '<a href="' . $buffer->get_login_url() . '">Connect to Buffer!</a>';
} else {
Logger::log("buffer_connect: authenticated");
Logger::notice("buffer_connect: authenticated");
$o = DI::l10n()->t("You are now authenticated to buffer. ");
$o .= '<br /><a href="' . DI::baseUrl()->get() . '/settings/connectors">' . DI::l10n()->t("return to the connector page") . '</a>';
DI::pConfig()->set(local_user(), 'buffer','access_token', $buffer->access_token);
@ -306,7 +306,7 @@ function buffer_send(App $a, array &$b)
$profiles = $buffer->go('/profiles');
if (is_array($profiles)) {
Logger::log("Will send these parameter ".print_r($b, true), Logger::DEBUG);
Logger::info("Will send these parameter ".print_r($b, true));
foreach ($profiles as $profile) {
if (!$profile->default)
@ -343,7 +343,7 @@ function buffer_send(App $a, array &$b)
$item = $b;
$post = Plaintext::getPost($item, $limit, $includedlinks, $htmlmode);
Logger::log("buffer_send: converted message ".$b["id"]." result: ".print_r($post, true), Logger::DEBUG);
Logger::info("buffer_send: converted message ".$b["id"]." result: ".print_r($post, true));
// The image proxy is used as a sanitizer. Buffer seems to be really picky about pictures
if (isset($post["image"])) {
@ -391,9 +391,9 @@ function buffer_send(App $a, array &$b)
}
//print_r($message);
Logger::log("buffer_send: data for message " . $b["id"] . ": " . print_r($message, true), Logger::DEBUG);
Logger::info("buffer_send: data for message " . $b["id"] . ": " . print_r($message, true));
$ret = $buffer->go('/updates/create', $message);
Logger::log("buffer_send: send message " . $b["id"] . " result: " . print_r($ret, true), Logger::DEBUG);
Logger::info("buffer_send: send message " . $b["id"] . " result: " . print_r($ret, true));
}
}
}

View File

@ -29,7 +29,7 @@ function catavatar_install()
Hook::register('addon_settings', 'addon/catavatar/catavatar.php', 'catavatar_addon_settings');
Hook::register('addon_settings_post', 'addon/catavatar/catavatar.php', 'catavatar_addon_settings_post');
Logger::log('registered catavatar');
Logger::notice('registered catavatar');
}
/**

View File

@ -184,7 +184,7 @@ function diaspora_send(App $a, array &$b)
{
$hostname = DI::baseUrl()->getHostname();
Logger::log('diaspora_send: invoked');
Logger::notice('diaspora_send: invoked');
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
return;
@ -208,14 +208,14 @@ function diaspora_send(App $a, array &$b)
return;
}
Logger::log('diaspora_send: prepare posting', Logger::DEBUG);
Logger::info('diaspora_send: prepare posting');
$handle = DI::pConfig()->get($b['uid'],'diaspora','handle');
$password = DI::pConfig()->get($b['uid'],'diaspora','password');
$aspect = DI::pConfig()->get($b['uid'],'diaspora','aspect');
if ($handle && $password) {
Logger::log('diaspora_send: all values seem to be okay', Logger::DEBUG);
Logger::info('diaspora_send: all values seem to be okay');
$title = $b['title'];
$body = $b['body'];
@ -246,20 +246,20 @@ function diaspora_send(App $a, array &$b)
require_once "addon/diaspora/diasphp.php";
try {
Logger::log('diaspora_send: prepare', Logger::DEBUG);
Logger::info('diaspora_send: prepare');
$conn = new Diaspora_Connection($handle, $password);
Logger::log('diaspora_send: try to log in '.$handle, Logger::DEBUG);
Logger::info('diaspora_send: try to log in '.$handle);
$conn->logIn();
Logger::log('diaspora_send: try to send '.$body, Logger::DEBUG);
Logger::info('diaspora_send: try to send '.$body);
$conn->provider = $hostname;
$conn->postStatusMessage($body, $aspect);
Logger::log('diaspora_send: success');
Logger::notice('diaspora_send: success');
} catch (Exception $e) {
Logger::log("diaspora_send: Error submitting the post: " . $e->getMessage());
Logger::notice("diaspora_send: Error submitting the post: " . $e->getMessage());
Logger::log('diaspora_send: requeueing '.$b['uid'], Logger::DEBUG);
Logger::info('diaspora_send: requeueing '.$b['uid']);
Worker::defer();
}

View File

@ -15,7 +15,7 @@ function fromapp_install()
Hook::register('post_local', 'addon/fromapp/fromapp.php', 'fromapp_post_hook');
Hook::register('addon_settings', 'addon/fromapp/fromapp.php', 'fromapp_settings');
Hook::register('addon_settings_post', 'addon/fromapp/fromapp.php', 'fromapp_settings_post');
Logger::log("installed fromapp");
Logger::notice("installed fromapp");
}
function fromapp_settings_post($a, $post)

View File

@ -48,25 +48,25 @@ function geocoordinates_resolve_item(&$item)
$s = DI::httpClient()->fetch("https://api.opencagedata.com/geocode/v1/json?q=" . $coords[0] . "," . $coords[1] . "&key=" . $key . "&language=" . $language);
if (!$s) {
Logger::log("API could not be queried", Logger::DEBUG);
Logger::info("API could not be queried");
return;
}
$data = json_decode($s);
if ($data->status->code != "200") {
Logger::log("API returned error ".$data->status->code." ".$data->status->message, Logger::DEBUG);
Logger::info("API returned error ".$data->status->code." ".$data->status->message);
return;
}
if (($data->total_results == 0) || (count($data->results) == 0)) {
Logger::log("No results found for coordinates ".$item["coord"], Logger::DEBUG);
Logger::info("No results found for coordinates ".$item["coord"]);
return;
}
$item["location"] = $data->results[0]->formatted;
Logger::log("Got location for coordinates ".$coords[0]."-".$coords[1].": ".$item["location"], Logger::DEBUG);
Logger::info("Got location for coordinates ".$coords[0]."-".$coords[1].": ".$item["location"]);
if ($item["location"] != "")
DI::cache()->set("geocoordinates:".$language.":".$coords[0]."-".$coords[1], $item["location"]);

View File

@ -46,7 +46,7 @@ function geonames_post_hook(App $a, array &$item)
* - The profile owner must have allowed our addon
*/
Logger::log('geonames invoked');
Logger::notice('geonames invoked');
if (!local_user()) { /* non-zero if this is a logged in user of this system */
return;

View File

@ -20,7 +20,7 @@ function gnot_install() {
Hook::register('addon_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post');
Hook::register('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail');
Logger::log("installed gnot");
Logger::notice("installed gnot");
}
/**

View File

@ -13,7 +13,7 @@ function googlemaps_install()
{
Hook::register('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
Logger::log("installed googlemaps");
Logger::notice("installed googlemaps");
}
function googlemaps_location($a, &$item)

View File

@ -14,7 +14,7 @@ function group_text_install() {
Hook::register('addon_settings', 'addon/group_text/group_text.php', 'group_text_settings');
Hook::register('addon_settings_post', 'addon/group_text/group_text.php', 'group_text_settings_post');
Logger::log("installed group_text");
Logger::notice("installed group_text");
}
/**

View File

@ -96,16 +96,16 @@ function ifttt_post(App $a)
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname]);
if (!DBA::isResult($user)) {
Logger::log('User ' . $nickname . ' not found.', Logger::DEBUG);
Logger::info('User ' . $nickname . ' not found.');
return;
}
$uid = $user['uid'];
Logger::log('Received a post for user ' . $uid . ' from ifttt ' . print_r($_REQUEST, true), Logger::DEBUG);
Logger::info('Received a post for user ' . $uid . ' from ifttt ' . print_r($_REQUEST, true));
if (!isset($_REQUEST['key'])) {
Logger::log('No key found.');
Logger::notice('No key found.');
return;
}
@ -113,7 +113,7 @@ function ifttt_post(App $a)
// Check the key
if ($key != DI::pConfig()->get($uid, 'ifttt', 'key')) {
Logger::log('Invalid key for user ' . $uid, Logger::DEBUG);
Logger::info('Invalid key for user ' . $uid);
return;
}
@ -124,7 +124,7 @@ function ifttt_post(App $a)
}
if (!in_array($item['type'], ['status', 'link', 'photo'])) {
Logger::log('Unknown item type ' . $item['type'], Logger::DEBUG);
Logger::info('Unknown item type ' . $item['type']);
return;
}

View File

@ -20,7 +20,7 @@ function impressum_install() {
Hook::register('load_config', 'addon/impressum/impressum.php', 'impressum_load_config');
Hook::register('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
Hook::register('page_end', 'addon/impressum/impressum.php', 'impressum_footer');
Logger::log("installed impressum Addon");
Logger::notice("installed impressum Addon");
}
function impressum_module() {

View File

@ -61,7 +61,7 @@ function js_upload_post_init(App $a, &$b)
$js_upload_jsonresponse = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
if (isset($result['error'])) {
Logger::log('mod/photos.php: photos_post(): error uploading photo: ' . $result['error'], Logger::DEBUG);
Logger::info('mod/photos.php: photos_post(): error uploading photo: ' . $result['error']);
echo json_encode($result);
exit();
}
@ -85,7 +85,7 @@ function js_upload_post_end(App $a, &$b)
{
global $js_upload_jsonresponse;
Logger::log('upload_post_end');
Logger::notice('upload_post_end');
if (!empty($js_upload_jsonresponse)) {
echo $js_upload_jsonresponse;
exit();

View File

@ -35,7 +35,7 @@ function krynn_install() {
Hook::register('addon_settings', 'addon/krynn/krynn.php', 'krynn_settings');
Hook::register('addon_settings_post', 'addon/krynn/krynn.php', 'krynn_settings_post');
Logger::log("installed krynn");
Logger::notice("installed krynn");
}
function krynn_post_hook($a, &$item) {

View File

@ -159,7 +159,7 @@ function leistungsschutzrecht_cron($a,$b) {
if($last) {
$next = $last + 86400;
if($next > time()) {
Logger::log('poll intervall not reached');
Logger::notice('poll intervall not reached');
return;
}
}

View File

@ -171,7 +171,7 @@ function libertree_post_local(&$a,&$b) {
function libertree_send(&$a,&$b) {
Logger::log('libertree_send: invoked');
Logger::notice('libertree_send: invoked');
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
return;
@ -236,6 +236,6 @@ function libertree_send(&$a,&$b) {
];
$result = DI::httpClient()->post($ltree_blog, $params)->getBody();
Logger::log('libertree: ' . $result);
Logger::notice('libertree: ' . $result);
}
}

View File

@ -16,7 +16,7 @@ use Friendica\Util\Strings;
function newmemberwidget_install()
{
Hook::register( 'network_mod_init', 'addon/newmemberwidget/newmemberwidget.php', 'newmemberwidget_network_mod_init');
Logger::log('newmemberwidget installed');
Logger::notice('newmemberwidget installed');
}
function newmemberwidget_network_mod_init ($a, $b)

View File

@ -14,7 +14,7 @@ function numfriends_install() {
Hook::register('addon_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings');
Hook::register('addon_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post');
Logger::log("installed numfriends");
Logger::notice("installed numfriends");
}
/**

View File

@ -31,7 +31,7 @@ function openstreetmap_install()
Hook::register('Map::getCoordinates', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_get_coordinates');
Hook::register('page_header', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_alterheader');
Logger::log("installed openstreetmap");
Logger::notice("installed openstreetmap");
}
function openstreetmap_load_config(\Friendica\App $a, ConfigFileLoader $loader)
@ -155,8 +155,8 @@ function openstreetmap_generate_map(&$a, &$b)
$lat = $b['lat']; // round($b['lat'], 5);
$lon = $b['lon']; // round($b['lon'], 5);
Logger::log('lat: ' . $lat, Logger::DATA);
Logger::log('lon: ' . $lon, Logger::DATA);
Logger::debug('lat: ' . $lat);
Logger::debug('lon: ' . $lon);
$cardlink = '<a href="' . $tmsserver;
@ -174,7 +174,7 @@ function openstreetmap_generate_map(&$a, &$b)
$b['html'] .= '<br/>' . $cardlink;
}
Logger::log('generate_map: ' . $b['html'], Logger::DATA);
Logger::debug('generate_map: ' . $b['html']);
}
function openstreetmap_addon_admin(&$a, &$o)

View File

@ -22,7 +22,7 @@ function opmlexport_install()
{
Hook::register('addon_settings', __FILE__, 'opmlexport_addon_settings');
Hook::register('addon_settings_post', __FILE__, 'opmlexport_addon_settings_post');
Logger::log('installed opmlexport Addon');
Logger::notice('installed opmlexport Addon');
}

View File

@ -42,7 +42,7 @@ function piwik_install() {
Hook::register('load_config', 'addon/piwik/piwik.php', 'piwik_load_config');
Hook::register('page_end', 'addon/piwik/piwik.php', 'piwik_analytics');
Logger::log("installed piwik addon");
Logger::notice("installed piwik addon");
}
function piwik_load_config(\Friendica\App $a, ConfigFileLoader $loader)

View File

@ -32,7 +32,7 @@ function planets_install() {
Hook::register('addon_settings', 'addon/planets/planets.php', 'planets_settings');
Hook::register('addon_settings_post', 'addon/planets/planets.php', 'planets_settings_post');
Logger::log("installed planets");
Logger::notice("installed planets");
}
function planets_post_hook($a, &$item) {
@ -46,7 +46,7 @@ function planets_post_hook($a, &$item) {
*
*/
Logger::log('planets invoked');
Logger::notice('planets invoked');
if(! local_user()) /* non-zero if this is a logged in user of this system */
return;

View File

@ -49,7 +49,7 @@ function public_server_register_account($a, $b)
function public_server_cron($a, $b)
{
Logger::log("public_server: cron start");
Logger::notice("public_server: cron start");
$users = DBA::selectToArray('user', [], ["`account_expires_on` < UTC_TIMESTAMP() + INTERVAL ? DAY AND
`account_expires_on` > ? AND `expire_notification_sent` <= ?", 5, DBA::NULL_DATETIME, DBA::NULL_DATETIME]);
@ -97,7 +97,7 @@ function public_server_cron($a, $b)
}
}
Logger::log("public_server: cron end");
Logger::notice("public_server: cron end");
}
function public_server_enotify(&$a, &$b)

View File

@ -10,7 +10,7 @@ function pumpio_sync_run($argv, $argc) {
if (function_exists('sys_getloadavg')) {
$load = sys_getloadavg();
if (intval($load[0]) > DI::config()->get('system', 'maxloadavg', 50)) {
Logger::log('system: load ' . $load[0] . ' too high. Pumpio sync deferred to next scheduled run.');
Logger::notice('system: load ' . $load[0] . ' too high. Pumpio sync deferred to next scheduled run.');
return;
}
}

View File

@ -44,7 +44,7 @@ function randplace_install() {
Hook::register('addon_settings', 'addon/randplace/randplace.php', 'randplace_settings');
Hook::register('addon_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post');
Logger::log("installed randplace");
Logger::notice("installed randplace");
}
@ -58,7 +58,7 @@ function randplace_uninstall() {
*
*/
Logger::log("removed randplace");
Logger::notice("removed randplace");
}
@ -74,7 +74,7 @@ function randplace_post_hook($a, &$item) {
*
*/
Logger::log('randplace invoked');
Logger::notice('randplace invoked');
if(! local_user()) /* non-zero if this is a logged in user of this system */
return;

View File

@ -23,7 +23,7 @@ function securemail_install()
Hook::register('emailer_send_prepare', 'addon/securemail/securemail.php', 'securemail_emailer_send_prepare', 10);
Logger::log('installed securemail');
Logger::notice('installed securemail');
}
/**

View File

@ -470,11 +470,11 @@ function tumblr_send(App $a, array &$b) {
//print_r($params);
if ($ret_code == 201) {
Logger::log('tumblr_send: success');
Logger::notice('tumblr_send: success');
} elseif ($ret_code == 403) {
Logger::log('tumblr_send: authentication failure');
Logger::notice('tumblr_send: authentication failure');
} else {
Logger::log('tumblr_send: general error: ' . print_r($x,true));
Logger::notice('tumblr_send: general error', ['error' => $x]);
}
}
}

View File

@ -1158,7 +1158,7 @@ function twitter_fetchtimeline(App $a, $uid)
}
}
DI::pConfig()->set($uid, 'twitter', 'lastid', $lastid);
Logger::log('Last ID for user ' . $uid . ' is now ' . $lastid, Logger::DEBUG);
Logger::info('Last ID for user ' . $uid . ' is now ' . $lastid);
}
function twitter_fix_avatar($avatar)
@ -1851,7 +1851,7 @@ function twitter_fetchparentposts(App $a, $uid, $post, TwitterOAuth $connection,
$posts[] = $post;
}
Logger::log("twitter_fetchparentposts: Fetching " . count($posts) . " parents", Logger::DEBUG);
Logger::info("twitter_fetchparentposts: Fetching " . count($posts) . " parents");
$posts = array_reverse($posts);
@ -1867,7 +1867,7 @@ function twitter_fetchparentposts(App $a, $uid, $post, TwitterOAuth $connection,
$postarray["id"] = $item;
Logger::log('twitter_fetchparentpost: User ' . $self["nick"] . ' posted parent timeline item ' . $item);
Logger::notice('twitter_fetchparentpost: User ' . $self["nick"] . ' posted parent timeline item ' . $item);
}
}
}
@ -1969,12 +1969,12 @@ function twitter_fetchhometimeline(App $a, $uid)
twitter_fetchparentposts($a, $uid, $post, $connection, $self);
}
Logger::log('Preparing post ' . $post->id_str . ' for user ' . $uid, Logger::DEBUG);
Logger::info('Preparing post ' . $post->id_str . ' for user ' . $uid);
$postarray = twitter_createpost($a, $uid, $post, $self, $create_user, true, false);
if (empty($postarray['body']) || trim($postarray['body']) == "") {
Logger::log('Empty body for post ' . $post->id_str . ' and user ' . $uid, Logger::DEBUG);
Logger::info('Empty body for post ' . $post->id_str . ' and user ' . $uid);
continue;
}
@ -1990,12 +1990,12 @@ function twitter_fetchhometimeline(App $a, $uid)
$item = Item::insert($postarray, $notify);
$postarray["id"] = $item;
Logger::log('User ' . $uid . ' posted home timeline item ' . $item);
Logger::notice('User ' . $uid . ' posted home timeline item ' . $item);
}
}
DI::pConfig()->set($uid, 'twitter', 'lasthometimelineid', $lastid);
Logger::log('Last timeline ID for user ' . $uid . ' is now ' . $lastid, Logger::DEBUG);
Logger::info('Last timeline ID for user ' . $uid . ' is now ' . $lastid);
// Fetching mentions
$lastid = DI::pConfig()->get($uid, 'twitter', 'lastmentionid');
@ -2020,7 +2020,7 @@ function twitter_fetchhometimeline(App $a, $uid)
$posts = array_reverse($items);
Logger::log("Fetching mentions for user " . $uid . " " . sizeof($posts) . " items", Logger::DEBUG);
Logger::info("Fetching mentions for user " . $uid . " " . sizeof($posts) . " items");
if (count($posts)) {
foreach ($posts as $post) {
@ -2044,13 +2044,13 @@ function twitter_fetchhometimeline(App $a, $uid)
$item = Item::insert($postarray);
Logger::log('User ' . $uid . ' posted mention timeline item ' . $item);
Logger::notice('User ' . $uid . ' posted mention timeline item ' . $item);
}
}
DI::pConfig()->set($uid, 'twitter', 'lastmentionid', $lastid);
Logger::log('Last mentions ID for user ' . $uid . ' is now ' . $lastid, Logger::DEBUG);
Logger::info('Last mentions ID for user ' . $uid . ' is now ' . $lastid);
}
function twitter_fetch_own_contact(App $a, $uid)

View File

@ -322,11 +322,11 @@ function wppost_send(&$a, &$b)
EOT;
Logger::log('wppost: data: ' . $xml, Logger::DATA);
Logger::debug('wppost: data: ' . $xml);
if ($wp_blog !== 'test') {
$x = DI::httpClient()->post($wp_blog, $xml)->getBody();
}
Logger::log('posted to wordpress: ' . (($x) ? $x : ''), Logger::DEBUG);
Logger::info('posted to wordpress: ' . (($x) ? $x : ''));
}
}