From 757a5c2de974ccf631e42a39b479a8a9de22a622 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 30 Aug 2022 19:45:30 +0000 Subject: [PATCH 1/4] Loglevels are adjusted --- mod/display.php | 2 +- mod/item.php | 10 +++++----- mod/photos.php | 6 +++--- mod/settings.php | 2 +- mod/tagger.php | 4 ++-- src/Contact/Avatar.php | 8 ++++---- src/Content/PageInfo.php | 4 ++-- src/Content/Text/BBCode.php | 14 +++++++------- src/Core/Addon.php | 6 +++--- src/Core/System.php | 22 +++++++++++----------- src/Core/Worker.php | 2 +- src/Core/Worker/Cron.php | 2 +- src/Database/DBStructure.php | 2 +- src/Model/Contact.php | 2 +- src/Model/Contact/Relation.php | 2 +- src/Model/Item.php | 8 ++++---- src/Model/Mail.php | 4 ++-- src/Model/Photo.php | 10 +++++----- src/Model/Post.php | 12 ++++++------ src/Protocol/ActivityPub/Delivery.php | 2 +- src/Protocol/DFRN.php | 25 ++++--------------------- src/Protocol/Diaspora.php | 8 ++++---- src/Protocol/Email.php | 10 +++++----- src/Util/DateTimeFormat.php | 2 +- src/Util/ParseUrl.php | 2 +- src/Util/XML.php | 6 +++--- src/Worker/Delivery.php | 8 ++++---- src/Worker/OnePoll.php | 2 +- src/Worker/RemoveUnusedAvatars.php | 2 +- src/Worker/RemoveUnusedContacts.php | 2 +- src/Worker/SpoolPost.php | 10 +++++----- view/theme/vier/style.php | 3 +-- 32 files changed, 93 insertions(+), 111 deletions(-) diff --git a/mod/display.php b/mod/display.php index ed2c9ef0f..5aba7eb81 100644 --- a/mod/display.php +++ b/mod/display.php @@ -102,7 +102,7 @@ function display_init(App $a) } if (!empty($_SERVER['HTTP_ACCEPT']) && strstr($_SERVER['HTTP_ACCEPT'], 'application/atom+xml')) { - Logger::info('Directly serving XML for uri-id '.$item['uri-id']); + Logger::debug('Directly serving XML', ['uri-id' => $item['uri-id']]); displayShowFeed($item['uri-id'], $item['uid'], false); } diff --git a/mod/item.php b/mod/item.php index 26dcef91c..6793d4434 100644 --- a/mod/item.php +++ b/mod/item.php @@ -89,7 +89,7 @@ function item_post(App $a) { */ if (!$preview && !empty($_REQUEST['post_id_random'])) { if (!empty($_SESSION['post-random']) && $_SESSION['post-random'] == $_REQUEST['post_id_random']) { - Logger::info('item post: duplicate post'); + Logger::warning('duplicate post'); item_post_return(DI::baseUrl(), $api_source, $return_path); } else { $_SESSION['post-random'] = $_REQUEST['post_id_random']; @@ -177,7 +177,7 @@ function item_post(App $a) { // Now check that valid personal details have been provided if (!Security::canWriteToUserWall($profile_uid) && !$allow_comment) { - Logger::notice('Permission denied.', ['local' => local_user(), 'profile_uid' => $profile_uid, 'toplevel_item_id' => $toplevel_item_id, 'network' => $toplevel_item['network']]); + Logger::warning('Permission denied.', ['local' => local_user(), 'profile_uid' => $profile_uid, 'toplevel_item_id' => $toplevel_item_id, 'network' => $toplevel_item['network']]); notice(DI::l10n()->t('Permission denied.')); if ($return_path) { DI::baseUrl()->redirect($return_path); @@ -755,7 +755,7 @@ function item_post(App $a) { } } - Logger::info('post_complete'); + Logger::debug('post_complete'); if ($api_source) { return $post_id; @@ -780,7 +780,7 @@ function item_post_return($baseurl, $api_source, $return_path) $json['reload'] = $baseurl . '/' . $_REQUEST['jsreload']; } - Logger::info('post_json', ['json' => $json]); + Logger::debug('post_json', ['json' => $json]); System::jsonExit($json); } @@ -866,7 +866,7 @@ function drop_item(int $id, string $return = '') item_redirect_after_action($item, $return); } else { - Logger::notice('Permission denied.', ['local' => local_user(), 'uid' => $item['uid'], 'cid' => $contact_id]); + Logger::warning('Permission denied.', ['local' => local_user(), 'uid' => $item['uid'], 'cid' => $contact_id]); notice(DI::l10n()->t('Permission denied.')); DI::baseUrl()->redirect('display/' . $item['guid']); //NOTREACHED diff --git a/mod/photos.php b/mod/photos.php index ed73f05de..8244ac2b8 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -304,7 +304,7 @@ function photos_post(App $a) } if (!empty($_POST['rotate']) && (intval($_POST['rotate']) == 1 || intval($_POST['rotate']) == 2)) { - Logger::notice('rotate'); + Logger::debug('rotate'); $photo = Photo::getPhotoForUser($page_owner_uid, $resource_id); @@ -580,7 +580,7 @@ function photos_post(App $a) $album = trim($_REQUEST['album'] ?? ''); $newalbum = trim($_REQUEST['newalbum'] ?? ''); - Logger::info('album= ' . $album . ' newalbum= ' . $newalbum); + Logger::debug('album= ' . $album . ' newalbum= ' . $newalbum); if (!strlen($album)) { if (strlen($newalbum)) { @@ -711,7 +711,7 @@ function photos_post(App $a) $r = Photo::store($image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 0 , Photo::DEFAULT, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny); if (!$r) { - Logger::info('image store failed'); + Logger::warning('image store failed'); notice(DI::l10n()->t('Image upload failed.')); return; } diff --git a/mod/settings.php b/mod/settings.php index 612907ac2..2e21c2682 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -108,7 +108,7 @@ function settings_post(App $a) 'pubmail' => $mail_pubmail ], ['uid' => local_user()]); - Logger::notice('updating mailaccount', ['response' => $r]); + Logger::debug('updating mailaccount', ['response' => $r]); $mailacct = DBA::selectFirst('mailacct', [], ['uid' => local_user()]); if (DBA::isResult($mailacct)) { $mb = Email::constructMailboxName($mailacct); diff --git a/mod/tagger.php b/mod/tagger.php index e674efba6..f4f77c08e 100644 --- a/mod/tagger.php +++ b/mod/tagger.php @@ -51,7 +51,7 @@ function tagger_content(App $a) { $item_id = ((DI::args()->getArgc() > 1) ? trim(DI::args()->getArgv()[1]) : 0); - Logger::notice('tagger: tag ' . $term . ' item ' . $item_id); + Logger::info('tagger: tag ' . $term . ' item ' . $item_id); $item = Post::selectFirst([], ['id' => $item_id]); @@ -69,7 +69,7 @@ function tagger_content(App $a) { $contact = Contact::selectFirst([], ['self' => true, 'uid' => local_user()]); if (!DBA::isResult($contact)) { - Logger::notice('tagger: no contact_id'); + Logger::warning('Self contact not found.', ['uid' => local_user()]); return; } diff --git a/src/Contact/Avatar.php b/src/Contact/Avatar.php index d03a5f4e6..d4368df22 100644 --- a/src/Contact/Avatar.php +++ b/src/Contact/Avatar.php @@ -165,11 +165,11 @@ class Avatar Logger::warning('Directory could not be created', ['directory' => $dirpath]); } } elseif ((($old_perm = fileperms($dirpath) & 0777) != $dir_perm) && !chmod($dirpath, $dir_perm)) { - Logger::notice('Directory permissions could not be changed', ['directory' => $dirpath, 'old' => $old_perm, 'new' => $dir_perm]); + Logger::warning('Directory permissions could not be changed', ['directory' => $dirpath, 'old' => $old_perm, 'new' => $dir_perm]); } if ((($old_group = filegroup($dirpath)) != $group) && !chgrp($dirpath, $group)) { - Logger::notice('Directory group could not be changed', ['directory' => $dirpath, 'old' => $old_group, 'new' => $group]); + Logger::warning('Directory group could not be changed', ['directory' => $dirpath, 'old' => $old_group, 'new' => $group]); } } @@ -181,11 +181,11 @@ class Avatar $old_group = filegroup($filepath); if (($old_perm != $file_perm) && !chmod($filepath, $file_perm)) { - Logger::notice('File permissions could not be changed', ['file' => $filepath, 'old' => $old_perm, 'new' => $file_perm]); + Logger::warning('File permissions could not be changed', ['file' => $filepath, 'old' => $old_perm, 'new' => $file_perm]); } if (($old_group != $group) && !chgrp($filepath, $group)) { - Logger::notice('File group could not be changed', ['file' => $filepath, 'old' => $old_group, 'new' => $group]); + Logger::warning('File group could not be changed', ['file' => $filepath, 'old' => $old_group, 'new' => $group]); } DI::profiler()->stopRecording(); diff --git a/src/Content/PageInfo.php b/src/Content/PageInfo.php index 71ffebc44..fa6a93994 100644 --- a/src/Content/PageInfo.php +++ b/src/Content/PageInfo.php @@ -42,7 +42,7 @@ class PageInfo */ public static function searchAndAppendToBody(string $body, bool $searchNakedUrls = false, bool $no_photos = false) { - Logger::info('add_page_info_to_body: fetch page info for body', ['body' => $body]); + Logger::debug('add_page_info_to_body: fetch page info for body', ['body' => $body]); $url = self::getRelevantUrlFromBody($body, $searchNakedUrls); if (!$url) { @@ -208,7 +208,7 @@ class PageInfo } } - Logger::info('fetch page info for URL', ['url' => $url, 'data' => $data]); + Logger::debug('fetch page info for URL', ['url' => $url, 'data' => $data]); return $data; } diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 7bb65b698..a46b55f38 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -498,7 +498,7 @@ class BBCode $c = preg_match_all('/\[img.*?\](.*?)\[\/img\]/ism', $s, $matches, PREG_SET_ORDER); if ($c) { foreach ($matches as $mtch) { - Logger::info('scale_external_image', ['image' => $mtch[1]]); + Logger::debug('scale_external_image', ['image' => $mtch[1]]); $hostname = str_replace('www.', '', substr(DI::baseUrl(), strpos(DI::baseUrl(), '://') + 3)); if (stristr($mtch[1], $hostname)) { @@ -526,14 +526,14 @@ class BBCode $Image->scaleDown(640); $new_width = $Image->getWidth(); $new_height = $Image->getHeight(); - Logger::info('External images scaled', ['orig_width' => $orig_width, 'new_width' => $new_width, 'orig_height' => $orig_height, 'new_height' => $new_height, 'match' => $mtch[0]]); + Logger::debug('External images scaled', ['orig_width' => $orig_width, 'new_width' => $new_width, 'orig_height' => $orig_height, 'new_height' => $new_height, 'match' => $mtch[0]]); $s = str_replace( $mtch[0], '[img=' . $new_width . 'x' . $new_height. ']' . $mtch[1] . '[/img]' . "\n", $s ); - Logger::info('New string', ['image' => $s]); + Logger::debug('New string', ['image' => $s]); } } } @@ -583,7 +583,7 @@ class BBCode if (($textlen + $img_start) > $maxlen) { if ($textlen < $maxlen) { - Logger::info('the limit happens before an embedded image'); + Logger::debug('the limit happens before an embedded image'); $new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen); $textlen = $maxlen; } @@ -597,7 +597,7 @@ class BBCode if (($textlen + $img_end) > $maxlen) { if ($textlen < $maxlen) { - Logger::info('the limit happens before the end of a non-embedded image'); + Logger::debug('the limit happens before the end of a non-embedded image'); $new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen); $textlen = $maxlen; } @@ -620,11 +620,11 @@ class BBCode if (($textlen + strlen($orig_body)) > $maxlen) { if ($textlen < $maxlen) { - Logger::info('the limit happens after the end of the last image'); + Logger::debug('the limit happens after the end of the last image'); $new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen); } } else { - Logger::info('the text size with embedded images extracted did not violate the limit'); + Logger::debug('the text size with embedded images extracted did not violate the limit'); $new_body = $new_body . $orig_body; } diff --git a/src/Core/Addon.php b/src/Core/Addon.php index 37ef335a4..ea5c3abf0 100644 --- a/src/Core/Addon.php +++ b/src/Core/Addon.php @@ -128,7 +128,7 @@ class Addon { $addon = Strings::sanitizeFilePathItem($addon); - Logger::notice("Addon {addon}: {action}", ['action' => 'uninstall', 'addon' => $addon]); + Logger::debug("Addon {addon}: {action}", ['action' => 'uninstall', 'addon' => $addon]); DBA::delete('addon', ['name' => $addon]); @include_once('addon/' . $addon . '/' . $addon . '.php'); @@ -160,7 +160,7 @@ class Addon return false; } - Logger::notice("Addon {addon}: {action}", ['action' => 'install', 'addon' => $addon]); + Logger::debug("Addon {addon}: {action}", ['action' => 'install', 'addon' => $addon]); $t = @filemtime($addon_file_path); @include_once($addon_file_path); if (function_exists($addon . '_install')) { @@ -200,7 +200,7 @@ class Addon continue; } - Logger::notice("Addon {addon}: {action}", ['action' => 'reload', 'addon' => $addon['name']]); + Logger::debug("Addon {addon}: {action}", ['action' => 'reload', 'addon' => $addon['name']]); self::uninstall($addon['name']); self::install($addon['name']); diff --git a/src/Core/System.php b/src/Core/System.php index 8712b6ca5..dbff4bf3f 100644 --- a/src/Core/System.php +++ b/src/Core/System.php @@ -493,30 +493,30 @@ class System * * @return boolean the directory is usable */ - public static function isDirectoryUsable($directory, $check_writable = true) + private static function isDirectoryUsable($directory, $check_writable = true) { if ($directory == '') { - Logger::info('Directory is empty. This shouldn\'t happen.'); + Logger::warning('Directory is empty. This shouldn\'t happen.'); return false; } if (!file_exists($directory)) { - Logger::info('Path "' . $directory . '" does not exist for user ' . static::getUser()); + Logger::warning('Path does not exist', ['directory' => $directory, 'user' => static::getUser()]); return false; } if (is_file($directory)) { - Logger::info('Path "' . $directory . '" is a file for user ' . static::getUser()); + Logger::warning('Path is a file', ['directory' => $directory, 'user' => static::getUser()]); return false; } if (!is_dir($directory)) { - Logger::info('Path "' . $directory . '" is not a directory for user ' . static::getUser()); + Logger::warning('Path is not a directory', ['directory' => $directory, 'user' => static::getUser()]); return false; } if ($check_writable && !is_writable($directory)) { - Logger::info('Path "' . $directory . '" is not writable for user ' . static::getUser()); + Logger::warning('Path is not writable', ['directory' => $directory, 'user' => static::getUser()]); return false; } @@ -550,7 +550,7 @@ class System { $temppath = DI::config()->get("system", "temppath"); - if (($temppath != "") && System::isDirectoryUsable($temppath)) { + if (($temppath != "") && self::isDirectoryUsable($temppath)) { // We have a temp path and it is usable return BasePath::getRealPath($temppath); } @@ -559,7 +559,7 @@ class System $temppath = sys_get_temp_dir(); // Check if it is usable - if (($temppath != "") && System::isDirectoryUsable($temppath)) { + if (($temppath != "") && self::isDirectoryUsable($temppath)) { // Always store the real path, not the path through symlinks $temppath = BasePath::getRealPath($temppath); @@ -570,7 +570,7 @@ class System mkdir($new_temppath); } - if (System::isDirectoryUsable($new_temppath)) { + if (self::isDirectoryUsable($new_temppath)) { // The new path is usable, we are happy DI::config()->set("system", "temppath", $new_temppath); return $new_temppath; @@ -593,7 +593,7 @@ class System public static function getSpoolPath() { $spoolpath = DI::config()->get('system', 'spoolpath'); - if (($spoolpath != "") && System::isDirectoryUsable($spoolpath)) { + if (($spoolpath != "") && self::isDirectoryUsable($spoolpath)) { // We have a spool path and it is usable return $spoolpath; } @@ -608,7 +608,7 @@ class System mkdir($spoolpath); } - if (System::isDirectoryUsable($spoolpath)) { + if (self::isDirectoryUsable($spoolpath)) { // The new path is usable, we are happy DI::config()->set("system", "spoolpath", $spoolpath); return $spoolpath; diff --git a/src/Core/Worker.php b/src/Core/Worker.php index 62fd321c2..8abb8c178 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -104,7 +104,7 @@ class Worker foreach ($r as $entry) { // The work will be done if (!self::execute($entry)) { - Logger::notice('Process execution failed, quitting.'); + Logger::warning('Process execution failed, quitting.'); return; } diff --git a/src/Core/Worker/Cron.php b/src/Core/Worker/Cron.php index 8df88e9e2..9db954298 100644 --- a/src/Core/Worker/Cron.php +++ b/src/Core/Worker/Cron.php @@ -101,7 +101,7 @@ class Cron // How long is the process already running? $duration = (time() - strtotime($entry["executed"])) / 60; if ($duration > $max_duration) { - Logger::notice('Worker process took too much time - killed', ['duration' => number_format($duration, 3), 'max' => $max_duration, 'id' => $entry["id"], 'pid' => $entry["pid"], 'command' => $command]); + Logger::warning('Worker process took too much time - killed', ['duration' => number_format($duration, 3), 'max' => $max_duration, 'id' => $entry["id"], 'pid' => $entry["pid"], 'command' => $command]); posix_kill($entry["pid"], SIGTERM); // We killed the stale process. diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index d14e791e2..2745f1cb8 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -119,7 +119,7 @@ class DBStructure $tables = array_merge($tables, DBA::selectToArray( 'information_schema.tables', ['table_name'], - ['engine' => 'InnoDB', 'ROW_FORMAT' => ['COMPACT', 'REDUNDANT'], 'table_schema' => DBA::databaseName()] + ['engine' => 'InnoDB', 'ROW_FORMAT' => ['COMPACT', 'REDUNDANT', 'COMPRESSED'], 'table_schema' => DBA::databaseName()] )); if (!DBA::isResult($tables)) { diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 8c8a25b6d..0408ea78a 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1299,7 +1299,7 @@ class Contact } if (!$contact_id) { - Logger::info('Contact was not inserted', ['url' => $url, 'uid' => $uid]); + Logger::warning('Contact was not inserted', ['url' => $url, 'uid' => $uid]); return 0; } } else { diff --git a/src/Model/Contact/Relation.php b/src/Model/Contact/Relation.php index ed520f25f..b8fd3aa95 100644 --- a/src/Model/Contact/Relation.php +++ b/src/Model/Contact/Relation.php @@ -108,7 +108,7 @@ class Relation $followings = []; } } else { - Logger::notice('Contact seems to be local but could not be found here', ['url' => $url]); + Logger::warning('Contact seems to be local but could not be found here', ['url' => $url]); $followers = []; $followings = []; } diff --git a/src/Model/Item.php b/src/Model/Item.php index eb150da45..5a3af646e 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -279,7 +279,7 @@ class Item if ($item['uid'] == $uid) { self::markForDeletionById($item['id'], PRIORITY_HIGH); } elseif ($item['uid'] != 0) { - Logger::notice('Wrong ownership. Not deleting item', ['id' => $item['id']]); + Logger::warning('Wrong ownership. Not deleting item', ['id' => $item['id']]); } } DBA::close($items); @@ -580,7 +580,7 @@ class Item if (!empty($item['uid'])) { $owner = User::getOwnerDataById($item['uid'], false); if (!$owner) { - Logger::notice('Missing item user owner data', ['uid' => $item['uid']]); + Logger::warning('Missing item user owner data', ['uid' => $item['uid']]); return false; } @@ -2515,7 +2515,7 @@ class Item $item = Post::selectFirst(self::ITEM_FIELDLIST, ['id' => $item_id]); if (!DBA::isResult($item)) { - Logger::notice('like: unknown item', ['id' => $item_id]); + Logger::warning('Post had not been fetched', ['id' => $item_id]); return false; } @@ -2581,7 +2581,7 @@ class Item $activity = Activity::ANNOUNCE; break; default: - Logger::notice('unknown verb', ['verb' => $verb, 'item' => $item_id]); + Logger::warning('unknown verb', ['verb' => $verb, 'item' => $item_id]); return false; } diff --git a/src/Model/Mail.php b/src/Model/Mail.php index afe3a3227..e494119cb 100644 --- a/src/Model/Mail.php +++ b/src/Model/Mail.php @@ -186,7 +186,7 @@ class Mail } if (!$convid) { - Logger::notice('send message: conversation not found.'); + Logger::warning('conversation not found.'); return -4; } @@ -290,7 +290,7 @@ class Mail } if (!$convid) { - Logger::notice('send message: conversation not found.'); + Logger::warning('conversation not found.'); return -4; } diff --git a/src/Model/Photo.php b/src/Model/Photo.php index 096915523..287fc65ad 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -1095,7 +1095,7 @@ class Photo $r = self::store($image, $user['uid'], 0, $resource_id, $filename, $album, 0, self::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc); if (!$r) { - Logger::notice('Photo could not be stored'); + Logger::warning('Photo could not be stored'); return []; } @@ -1182,7 +1182,7 @@ class Photo $r = self::store($image, $uid, 0, $resource_id, $filename, $album, 4, self::USER_AVATAR); if (!$r) { - logger::notice('profile image upload with scale 4 (300) failed'); + logger::warning('profile image upload with scale 4 (300) failed'); } if ($width > 80 || $height > 80) { @@ -1191,7 +1191,7 @@ class Photo $r = self::store($image, $uid, 0, $resource_id, $filename, $album, 5, self::USER_AVATAR); if (!$r) { - logger::notice('profile image upload with scale 5 (80) failed'); + logger::warning('profile image upload with scale 5 (80) failed'); } if ($width > 48 || $height > 48) { @@ -1200,7 +1200,7 @@ class Photo $r = self::store($image, $uid, 0, $resource_id, $filename, $album, 6, self::USER_AVATAR); if (!$r) { - logger::notice('profile image upload with scale 6 (48) failed'); + logger::warning('profile image upload with scale 6 (48) failed'); } logger::info('new profile image upload ended'); @@ -1257,7 +1257,7 @@ class Photo $r = self::store($image, $uid, 0, $resource_id, $filename, $album, 3, self::USER_BANNER); if (!$r) { - logger::notice('profile banner upload with scale 3 (960) failed'); + logger::warning('profile banner upload with scale 3 (960) failed'); } logger::info('new profile banner upload ended'); diff --git a/src/Model/Post.php b/src/Model/Post.php index 59fbb491e..4b1d70ae9 100644 --- a/src/Model/Post.php +++ b/src/Model/Post.php @@ -533,7 +533,7 @@ class Post $puids = array_column($rows, 'post-user-id'); if (!DBA::update('post-user', $update_fields, ['id' => $puids])) { DBA::rollback(); - Logger::notice('Updating post-user failed', ['fields' => $update_fields, 'condition' => $condition]); + Logger::warning('Updating post-user failed', ['fields' => $update_fields, 'condition' => $condition]); return false; } $affected_count += DBA::affectedRows(); @@ -550,7 +550,7 @@ class Post $uriids = array_column($rows, 'uri-id'); if (!DBA::update('post-content', $update_fields, ['uri-id' => $uriids])) { DBA::rollback(); - Logger::notice('Updating post-content failed', ['fields' => $update_fields, 'condition' => $condition]); + Logger::warning('Updating post-content failed', ['fields' => $update_fields, 'condition' => $condition]); return false; } $affected_count += DBA::affectedRows(); @@ -573,7 +573,7 @@ class Post if (!DBA::update('post', $update_fields, ['uri-id' => $uriids])) { DBA::rollback(); - Logger::notice('Updating post failed', ['fields' => $update_fields, 'condition' => $condition]); + Logger::warning('Updating post failed', ['fields' => $update_fields, 'condition' => $condition]); return false; } $affected_count += DBA::affectedRows(); @@ -590,7 +590,7 @@ class Post $uriids = array_column($rows, 'uri-id'); if (!DBA::update('post-delivery-data', $update_fields, ['uri-id' => $uriids])) { DBA::rollback(); - Logger::notice('Updating post-delivery-data failed', ['fields' => $update_fields, 'condition' => $condition]); + Logger::warning('Updating post-delivery-data failed', ['fields' => $update_fields, 'condition' => $condition]); return false; } $affected_count += DBA::affectedRows(); @@ -607,7 +607,7 @@ class Post $uriids = array_column($rows, 'uri-id'); if (!DBA::update('post-thread', $update_fields, ['uri-id' => $uriids])) { DBA::rollback(); - Logger::notice('Updating post-thread failed', ['fields' => $update_fields, 'condition' => $condition]); + Logger::warning('Updating post-thread failed', ['fields' => $update_fields, 'condition' => $condition]); return false; } $affected_count += DBA::affectedRows(); @@ -624,7 +624,7 @@ class Post $thread_puids = array_column($rows, 'post-user-id'); if (!DBA::update('post-thread-user', $update_fields, ['post-user-id' => $thread_puids])) { DBA::rollback(); - Logger::notice('Updating post-thread-user failed', ['fields' => $update_fields, 'condition' => $condition]); + Logger::warning('Updating post-thread-user failed', ['fields' => $update_fields, 'condition' => $condition]); return false; } $affected_count += DBA::affectedRows(); diff --git a/src/Protocol/ActivityPub/Delivery.php b/src/Protocol/ActivityPub/Delivery.php index 38f1f52b9..4f1bec61c 100644 --- a/src/Protocol/ActivityPub/Delivery.php +++ b/src/Protocol/ActivityPub/Delivery.php @@ -82,7 +82,7 @@ class Delivery if (empty($item_id) && !empty($uri_id) && !empty($uid)) { $item = Post::selectFirst(['id', 'parent', 'origin'], ['uri-id' => $uri_id, 'uid' => [$uid, 0]], ['order' => ['uid' => true]]); if (empty($item['id'])) { - Logger::notice('Item not found, removing delivery', ['uri-id' => $uri_id, 'uid' => $uid, 'cmd' => $cmd, 'inbox' => $inbox]); + Logger::warning('Item not found, removing delivery', ['uri-id' => $uri_id, 'uid' => $uid, 'cmd' => $cmd, 'inbox' => $inbox]); Post\Delivery::remove($uri_id, $inbox); return true; } else { diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 80e92fa15..434af8980 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -747,7 +747,7 @@ class DFRN $mentioned = []; if (!$item['parent']) { - Logger::notice('Item without parent found.', ['type' => $type, 'item' => $item]); + Logger::warning('Item without parent found.', ['type' => $type, 'item' => $item]); return null; } @@ -1466,9 +1466,8 @@ class DFRN // update contact $old = Contact::selectFirst(['photo', 'url'], ['id' => $importer['id'], 'uid' => $importer['importer_uid']]); - if (!DBA::isResult($old)) { - Logger::notice("Query failed to execute, no result returned in " . __FUNCTION__); + Logger::warning('Existing contact had not been fetched', ['id' => $importer['id']]); return false; } @@ -1550,24 +1549,9 @@ class DFRN private static function getEntryType(array $importer, array $item): int { if ($item['thr-parent'] != $item['uri']) { - $community = false; - - if ($importer['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) { - $sql_extra = ''; - $community = true; - Logger::notice("possible community action"); - } else { - $sql_extra = " AND `self` AND `wall`"; - } - // was the top-level post for this action written by somebody on this site? // Specifically, the recipient? - $parent = Post::selectFirst(['wall'], - ["`uri` = ? AND `uid` = ?" . $sql_extra, $item['thr-parent'], $importer['importer_uid']]); - - $is_a_remote_action = DBA::isResult($parent); - - if ($is_a_remote_action) { + if (Post::exists(['uri' => $item['thr-parent'], 'uid' => $importer['importer_uid'], 'self' => true, 'wall' => true])) { return DFRN::REPLY_RC; } else { return DFRN::REPLY; @@ -1665,9 +1649,8 @@ class DFRN if ($xt->type == Activity\ObjectType::NOTE) { $item_tag = Post::selectFirst(['id', 'uri-id'], ['uri' => $xt->id, 'uid' => $importer['importer_uid']]); - if (!DBA::isResult($item_tag)) { - Logger::notice("Query failed to execute, no result returned in " . __FUNCTION__); + Logger::warning('Post had not been fetched', ['uri' => $xt->id, 'uid' => $importer['importer_uid']]); return false; } diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index c12912f68..45798cc57 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -475,7 +475,7 @@ class Diaspora } if (!($fields = self::validPosting($msg))) { - Logger::notice('Invalid posting'); + Logger::warning('Invalid posting'); return false; } @@ -510,7 +510,7 @@ class Diaspora if (is_null($fields)) { $private = true; if (!($fields = self::validPosting($msg))) { - Logger::notice('Invalid posting'); + Logger::warning('Invalid posting'); return false; } } else { @@ -1711,7 +1711,7 @@ class Diaspora } } if (!$conversation) { - Logger::notice('Unable to create conversation.'); + Logger::warning('Unable to create conversation.'); return false; } @@ -3644,7 +3644,7 @@ class Diaspora $attend_answer = 'tentative'; break; default: - Logger::notice('Unknown verb ' . $item['verb'] . ' in item ' . $item['guid']); + Logger::warning('Unknown verb ' . $item['verb'] . ' in item ' . $item['guid']); return false; } diff --git a/src/Protocol/Email.php b/src/Protocol/Email.php index 577760a25..bcde2b4e2 100644 --- a/src/Protocol/Email.php +++ b/src/Protocol/Email.php @@ -51,12 +51,12 @@ class Email $errors = imap_errors(); if (!empty($errors)) { - Logger::notice('IMAP Errors occured', ['errors' => $errors]); + Logger::warning('IMAP Errors occured', ['errors' => $errors]); } $alerts = imap_alerts(); if (!empty($alerts)) { - Logger::notice('IMAP Alerts occured: ', ['alerts' => $alerts]); + Logger::warning('IMAP Alerts occured: ', ['alerts' => $alerts]); } return $mbox; @@ -78,21 +78,21 @@ class Email if (!$search1) { $search1 = []; } else { - Logger::notice("Found mails from ".$email_addr); + Logger::debug("Found mails from ".$email_addr); } $search2 = @imap_search($mbox, 'UNDELETED TO "' . $email_addr . '"', SE_UID); if (!$search2) { $search2 = []; } else { - Logger::notice("Found mails to ".$email_addr); + Logger::debug("Found mails to ".$email_addr); } $search3 = @imap_search($mbox, 'UNDELETED CC "' . $email_addr . '"', SE_UID); if (!$search3) { $search3 = []; } else { - Logger::notice("Found mails cc ".$email_addr); + Logger::debug("Found mails cc ".$email_addr); } $res = array_unique(array_merge($search1, $search2, $search3)); diff --git a/src/Util/DateTimeFormat.php b/src/Util/DateTimeFormat.php index 41cd16d2f..872b95228 100644 --- a/src/Util/DateTimeFormat.php +++ b/src/Util/DateTimeFormat.php @@ -158,7 +158,7 @@ class DateTimeFormat try { $d = new DateTime($s, $from_obj); } catch (Exception $e) { - Logger::notice('DateTimeFormat::convert: exception: ' . $e->getMessage()); + Logger::warning('DateTimeFormat::convert: exception: ' . $e->getMessage()); $d = new DateTime('now', $from_obj); } diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index 0b4bf9c95..4611cf8ef 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -214,7 +214,7 @@ class ParseUrl ]; if ($count > 10) { - Logger::notice('Endless loop detected', ['url' => $url]); + Logger::warning('Endless loop detected', ['url' => $url]); return $siteinfo; } diff --git a/src/Util/XML.php b/src/Util/XML.php index c2721d247..7933f4415 100644 --- a/src/Util/XML.php +++ b/src/Util/XML.php @@ -270,7 +270,7 @@ class XML } if (!function_exists('xml_parser_create')) { - Logger::notice('Xml::toArray: parser function missing'); + Logger::error('Xml::toArray: parser function missing'); return []; } @@ -285,8 +285,8 @@ class XML $parser = @xml_parser_create(); } - if (! $parser) { - Logger::notice('Xml::toArray: xml_parser_create: no resource'); + if (!$parser) { + Logger::warning('Xml::toArray: xml_parser_create: no resource'); return []; } diff --git a/src/Worker/Delivery.php b/src/Worker/Delivery.php index f1acd8fd4..786f71a66 100644 --- a/src/Worker/Delivery.php +++ b/src/Worker/Delivery.php @@ -103,12 +103,12 @@ class Delivery DBA::close($itemdata); if (empty($target_item)) { - Logger::notice('Item ' . $target_id . "wasn't found. Quitting here."); + Logger::warning('Item ' . $target_id . "wasn't found. Quitting here."); return; } if (empty($parent)) { - Logger::notice('Parent ' . $parent_id . ' for item ' . $target_id . "wasn't found. Quitting here."); + Logger::warning('Parent ' . $parent_id . ' for item ' . $target_id . "wasn't found. Quitting here."); self::setFailedQueue($cmd, $target_item); return; } @@ -182,7 +182,7 @@ class Delivery } if (empty($items)) { - Logger::notice('No delivery data', ['command' => $cmd, 'uri-id' => $post_uriid, 'cid' => $contact_id]); + Logger::warning('No delivery data', ['command' => $cmd, 'uri-id' => $post_uriid, 'cid' => $contact_id]); } $owner = Model\User::getOwnerDataById($uid); @@ -432,7 +432,7 @@ class Delivery Logger::notice('diaspora status: ' . $loc); $deliver_status = Diaspora::sendStatus($target_item, $owner, $contact, $public_message); } else { - Logger::notice('Unknown mode ' . $cmd . ' for ' . $loc); + Logger::warning('Unknown mode', ['command' => $cmd, 'target' => $loc]); return; } diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php index 719bd373c..83a7a5f15 100644 --- a/src/Worker/OnePoll.php +++ b/src/Worker/OnePoll.php @@ -394,7 +394,7 @@ class OnePoll $datarray = Email::getMessage($mbox, $msg_uid, $reply, $datarray); if (empty($datarray['body'])) { - Logger::notice("Mail: can't fetch msg ".$msg_uid." for ".$mailconf['user']); + Logger::warning('Cannot fetch mail', ['msg-id' => $msg_uid, 'uid' => $mailconf['user']]); continue; } diff --git a/src/Worker/RemoveUnusedAvatars.php b/src/Worker/RemoveUnusedAvatars.php index 8adc7d76d..4591fb22b 100644 --- a/src/Worker/RemoveUnusedAvatars.php +++ b/src/Worker/RemoveUnusedAvatars.php @@ -56,7 +56,7 @@ class RemoveUnusedAvatars Logger::notice('We are outside of the maintenance window, quitting'); return; } - Logger::notice('In removal', ['count' => $count, 'total' => $total]); + Logger::info('In removal', ['count' => $count, 'total' => $total]); } } DBA::close($contacts); diff --git a/src/Worker/RemoveUnusedContacts.php b/src/Worker/RemoveUnusedContacts.php index 324ec2419..6a4199634 100644 --- a/src/Worker/RemoveUnusedContacts.php +++ b/src/Worker/RemoveUnusedContacts.php @@ -80,7 +80,7 @@ class RemoveUnusedContacts DBA::delete('contact', ['id' => $contact['id']]); if ((++$count % 1000) == 0) { - Logger::notice('In removal', ['count' => $count, 'total' => $total]); + Logger::info('In removal', ['count' => $count, 'total' => $total]); } } DBA::close($contacts); diff --git a/src/Worker/SpoolPost.php b/src/Worker/SpoolPost.php index 884c5fd49..ee5412d7f 100644 --- a/src/Worker/SpoolPost.php +++ b/src/Worker/SpoolPost.php @@ -38,7 +38,7 @@ class SpoolPost { // It is not named like a spool file, so we don't care. if (substr($file, 0, 5) != "item-") { - Logger::notice('Spool file does does not start with "item-"', ['file' => $file]); + Logger::info('Spool file does does not start with "item-"', ['file' => $file]); continue; } @@ -46,13 +46,13 @@ class SpoolPost { // We don't care about directories either if (filetype($fullfile) != "file") { - Logger::notice('Spool file is no file', ['file' => $file]); + Logger::info('Spool file is no file', ['file' => $file]); continue; } // We can't read or write the file? So we don't care about it. if (!is_writable($fullfile) || !is_readable($fullfile)) { - Logger::notice('Spool file has insufficent permissions', ['file' => $file, 'writable' => is_writable($fullfile), 'readable' => is_readable($fullfile)]); + Logger::warning('Spool file has insufficent permissions', ['file' => $file, 'writable' => is_writable($fullfile), 'readable' => is_readable($fullfile)]); continue; } @@ -66,13 +66,13 @@ class SpoolPost { // Skip if it doesn't seem to be an item array if (!isset($arr['uid']) && !isset($arr['uri']) && !isset($arr['network'])) { - Logger::notice('Spool file does not contain the needed fields', ['file' => $file]); + Logger::warning('Spool file does not contain the needed fields', ['file' => $file]); continue; } $result = Item::insert($arr); - Logger::notice('Spool file is stored', ['file' => $file, 'result' => $result]); + Logger::info('Spool file is stored', ['file' => $file, 'result' => $result]); unlink($fullfile); } closedir($dh); diff --git a/view/theme/vier/style.php b/view/theme/vier/style.php index ff888dac6..74975893c 100644 --- a/view/theme/vier/style.php +++ b/view/theme/vier/style.php @@ -49,8 +49,7 @@ foreach (['style', $style] as $file) { $modified = $stylemodified; } } else { - //TODO: use Logger::ERROR? - Logger::notice('Error: missing file: "' . $stylecssfile .'" (userid: '. $uid .')'); + Logger::warning('Missing CSS file', ['file' => $stylecssfile, 'uid' => $uid]); } } $modified = gmdate('r', $modified); From f7b85092b0e3c3daff264a9189aa3ac1f654a6b7 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 31 Aug 2022 05:01:22 +0000 Subject: [PATCH 2/4] Some more changed log levels --- mod/photos.php | 4 ++-- src/Model/Tag.php | 4 ++-- src/Module/BaseApi.php | 6 +++--- src/Module/DFRN/Notify.php | 4 ++-- src/Module/OAuth/Revoke.php | 2 +- src/Module/OAuth/Token.php | 2 +- src/Module/Photo.php | 2 +- src/Module/Proxy.php | 8 ++++---- src/Protocol/ActivityPub/Delivery.php | 4 ++-- src/Protocol/ActivityPub/Processor.php | 7 ++++--- src/Protocol/ActivityPub/Receiver.php | 5 +++++ src/Protocol/OStatus.php | 2 +- src/Security/OAuth.php | 2 +- src/Worker/Delivery.php | 2 +- 14 files changed, 30 insertions(+), 24 deletions(-) diff --git a/mod/photos.php b/mod/photos.php index 8244ac2b8..6a4596bf2 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -678,14 +678,14 @@ function photos_post(App $a) return; } - Logger::info('loading the contents of ' . $src); + Logger::debug('loading contents', ['src' => $src]); $imagedata = @file_get_contents($src); $image = new Image($imagedata, $type); if (!$image->isValid()) { - Logger::info('unable to process image'); + Logger::notice('unable to process image'); notice(DI::l10n()->t('Unable to process image.')); @unlink($src); $foo = 0; diff --git a/src/Model/Tag.php b/src/Model/Tag.php index 9204dea2d..435dfda7c 100644 --- a/src/Model/Tag.php +++ b/src/Model/Tag.php @@ -156,7 +156,7 @@ class Tag DBA::insert('post-tag', $fields, Database::INSERT_IGNORE); - Logger::info('Stored tag/mention', ['uri-id' => $uriId, 'tag-id' => $tagid, 'contact-id' => $cid, 'name' => $name, 'type' => $type, 'callstack' => System::callstack(8)]); + Logger::debug('Stored tag/mention', ['uri-id' => $uriId, 'tag-id' => $tagid, 'contact-id' => $cid, 'name' => $name, 'type' => $type, 'callstack' => System::callstack(8)]); } /** @@ -389,7 +389,7 @@ class Tag return; } - Logger::info('Removing tag/mention', ['uri-id' => $uriId, 'tid' => $tag['tid'], 'name' => $name, 'url' => $url, 'callstack' => System::callstack(8)]); + Logger::debug('Removing tag/mention', ['uri-id' => $uriId, 'tid' => $tag['tid'], 'name' => $name, 'url' => $url, 'callstack' => System::callstack(8)]); DBA::delete('post-tag', ['uri-id' => $uriId, 'type' => $type, 'tid' => $tag['tid'], 'cid' => $tag['cid']]); } diff --git a/src/Module/BaseApi.php b/src/Module/BaseApi.php index f39a40cde..1ed0b9033 100644 --- a/src/Module/BaseApi.php +++ b/src/Module/BaseApi.php @@ -237,7 +237,7 @@ class BaseApi extends BaseModule $posts_day = Post::countThread($condition); if ($posts_day > $throttle_day) { - Logger::info('Daily posting limit reached', ['uid' => $uid, 'posts' => $posts_day, 'limit' => $throttle_day]); + Logger::notice('Daily posting limit reached', ['uid' => $uid, 'posts' => $posts_day, 'limit' => $throttle_day]); $error = DI::l10n()->t('Too Many Requests'); $error_description = DI::l10n()->tt("Daily posting limit of %d post reached. The post was rejected.", "Daily posting limit of %d posts reached. The post was rejected.", $throttle_day); $errorobj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description); @@ -253,7 +253,7 @@ class BaseApi extends BaseModule $posts_week = Post::countThread($condition); if ($posts_week > $throttle_week) { - Logger::info('Weekly posting limit reached', ['uid' => $uid, 'posts' => $posts_week, 'limit' => $throttle_week]); + Logger::notice('Weekly posting limit reached', ['uid' => $uid, 'posts' => $posts_week, 'limit' => $throttle_week]); $error = DI::l10n()->t('Too Many Requests'); $error_description = DI::l10n()->tt("Weekly posting limit of %d post reached. The post was rejected.", "Weekly posting limit of %d posts reached. The post was rejected.", $throttle_week); $errorobj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description); @@ -269,7 +269,7 @@ class BaseApi extends BaseModule $posts_month = Post::countThread($condition); if ($posts_month > $throttle_month) { - Logger::info('Monthly posting limit reached', ['uid' => $uid, 'posts' => $posts_month, 'limit' => $throttle_month]); + Logger::notice('Monthly posting limit reached', ['uid' => $uid, 'posts' => $posts_month, 'limit' => $throttle_month]); $error = DI::l10n()->t('Too Many Requests'); $error_description = DI::l10n()->tt('Monthly posting limit of %d post reached. The post was rejected.', 'Monthly posting limit of %d posts reached. The post was rejected.', $throttle_month); $errorobj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description); diff --git a/src/Module/DFRN/Notify.php b/src/Module/DFRN/Notify.php index 090ed3492..08ec7340c 100644 --- a/src/Module/DFRN/Notify.php +++ b/src/Module/DFRN/Notify.php @@ -82,7 +82,7 @@ class Notify extends BaseModule System::xmlExit(3, 'Contact ' . $msg['author'] . ' not found'); } - Logger::info('Importing post with the public envelope.', ['transmitter' => $msg['author']]); + Logger::debug('Importing post with the public envelope.', ['transmitter' => $msg['author']]); // Now we should be able to import it $ret = DFRN::import($msg['message'], $importer, Conversation::PARCEL_DIASPORA_DFRN, Conversation::RELAY); @@ -117,7 +117,7 @@ class Notify extends BaseModule System::xmlExit(3, 'Contact ' . $msg['author'] . ' not found'); } - Logger::info('Importing post with the private envelope.', ['transmitter' => $msg['author'], 'receiver' => $user['nickname']]); + Logger::debug('Importing post with the private envelope.', ['transmitter' => $msg['author'], 'receiver' => $user['nickname']]); // Now we should be able to import it $ret = DFRN::import($msg['message'], $importer, Conversation::PARCEL_DIASPORA_DFRN, Conversation::PUSH); diff --git a/src/Module/OAuth/Revoke.php b/src/Module/OAuth/Revoke.php index a9be6e265..0604e90bf 100644 --- a/src/Module/OAuth/Revoke.php +++ b/src/Module/OAuth/Revoke.php @@ -49,7 +49,7 @@ class Revoke extends BaseApi $condition = ['client_id' => $request['client_id'], 'client_secret' => $request['client_secret'], 'access_token' => $request['token']]; $token = DBA::selectFirst('application-view', ['id'], $condition); if (empty($token['id'])) { - Logger::warning('Token not found', $condition); + Logger::notice('Token not found', $condition); DI::mstdnError()->Unauthorized(); } diff --git a/src/Module/OAuth/Token.php b/src/Module/OAuth/Token.php index 020dd931a..1da8df18d 100644 --- a/src/Module/OAuth/Token.php +++ b/src/Module/OAuth/Token.php @@ -88,7 +88,7 @@ class Token extends BaseApi $token = DBA::selectFirst('application-view', ['access_token', 'created_at'], $condition); if (!DBA::isResult($token)) { - Logger::warning('Token not found or outdated', $condition); + Logger::notice('Token not found or outdated', $condition); DI::mstdnError()->Unauthorized(); } } else { diff --git a/src/Module/Photo.php b/src/Module/Photo.php index c521d2be8..076dc8107 100644 --- a/src/Module/Photo.php +++ b/src/Module/Photo.php @@ -219,7 +219,7 @@ class Photo extends BaseModule $rest = $total - ($fetch + $data + $checksum + $output); if (!is_null($scale) && ($scale < 4)) { - Logger::info('Performance:', ['scale' => $scale, 'resource' => $photo['resource-id'], + Logger::debug('Performance:', ['scale' => $scale, 'resource' => $photo['resource-id'], 'total' => number_format($total, 3), 'fetch' => number_format($fetch, 3), 'data' => number_format($data, 3), 'checksum' => number_format($checksum, 3), 'output' => number_format($output, 3), 'rest' => number_format($rest, 3)]); diff --git a/src/Module/Proxy.php b/src/Module/Proxy.php index cff5ed90b..7aecf682d 100644 --- a/src/Module/Proxy.php +++ b/src/Module/Proxy.php @@ -75,7 +75,7 @@ class Proxy extends BaseModule } if (!local_user()) { - Logger::info('Redirecting not logged in user to original address', ['url' => $request['url']]); + Logger::debug('Redirecting not logged in user to original address', ['url' => $request['url']]); System::externalRedirect($request['url']); } @@ -87,7 +87,7 @@ class Proxy extends BaseModule $img_str = $fetchResult->getBody(); if (!$fetchResult->isSuccess() || empty($img_str)) { - Logger::info('Error fetching image', ['image' => $request['url'], 'return' => $fetchResult->getReturnCode(), 'empty' => empty($img_str)]); + Logger::notice('Error fetching image', ['image' => $request['url'], 'return' => $fetchResult->getReturnCode(), 'empty' => empty($img_str)]); self::responseError(); // stop. } @@ -98,7 +98,7 @@ class Proxy extends BaseModule $image = new Image($img_str, $mime); if (!$image->isValid()) { - Logger::info('The image is invalid', ['image' => $request['url'], 'mime' => $mime]); + Logger::notice('The image is invalid', ['image' => $request['url'], 'mime' => $mime]); self::responseError(); // stop. } @@ -193,7 +193,7 @@ class Proxy extends BaseModule private static function responseImageHttpCache(Image $img) { if (is_null($img) || !$img->isValid()) { - Logger::info('The cached image is invalid'); + Logger::notice('The cached image is invalid'); self::responseError(); // stop. } diff --git a/src/Protocol/ActivityPub/Delivery.php b/src/Protocol/ActivityPub/Delivery.php index 4f1bec61c..9aa45d041 100644 --- a/src/Protocol/ActivityPub/Delivery.php +++ b/src/Protocol/ActivityPub/Delivery.php @@ -52,7 +52,7 @@ class Delivery if ($result['serverfailure']) { // In a timeout situation we assume that every delivery to that inbox will time out. // So we set the flag and try all deliveries at a later time. - Logger::info('Inbox delivery has a server failure', ['inbox' => $inbox]); + Logger::notice('Inbox delivery has a server failure', ['inbox' => $inbox]); $serverfail = true; } } @@ -151,7 +151,7 @@ class Delivery } - Logger::info('Delivery failed', ['retcode' => $response->getReturnCode(), 'serverfailure' => $serverfail, 'drop' => $drop, 'runtime' => round($runtime, 3), 'uri-id' => $uri_id, 'uid' => $uid, 'item_id' => $item_id, 'cmd' => $cmd, 'inbox' => $inbox]); + Logger::notice('Delivery failed', ['retcode' => $response->getReturnCode(), 'serverfailure' => $serverfail, 'drop' => $drop, 'runtime' => round($runtime, 3), 'uri-id' => $uri_id, 'uid' => $uid, 'item_id' => $item_id, 'cmd' => $cmd, 'inbox' => $inbox]); } if ($uri_id) { if ($success) { diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index 668b8a5b8..5889d9f6e 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -357,7 +357,7 @@ class Processor $item['diaspora_signed_text'] = $activity['diaspora:comment'] ?? ''; if (empty($conversation) && empty($activity['directmessage']) && ($item['gravity'] != GRAVITY_PARENT) && !Post::exists(['uri' => $item['thr-parent']])) { - Logger::info('Parent not found, message will be discarded.', ['thr-parent' => $item['thr-parent']]); + Logger::notice('Parent not found, message will be discarded.', ['thr-parent' => $item['thr-parent']]); if (!$fetch_parents) { Queue::remove($activity); } @@ -657,6 +657,7 @@ class Processor $activity['reply-to-id'] = $activity['object_id']; $item = self::createItem($activity, false); if (empty($item)) { + Logger::debug('Activity was not prepared', ['id' => $activity['object_id']]); return; } @@ -1304,7 +1305,7 @@ class Processor $pcid = Contact::getIdForURL($url, 0, false); if (empty($pcid)) { - Logger::info('Contact not found', ['contact' => $url]); + Logger::notice('Contact not found', ['contact' => $url]); return; } @@ -1364,7 +1365,7 @@ class Processor public static function fetchCachedActivity(string $url, int $uid): array { - $cachekey = self::CACHEKEY_FETCH_ACTIVITY . $uid . ':' . $url; + $cachekey = self::CACHEKEY_FETCH_ACTIVITY . $uid . ':' . hash('sha256', $url); $object = DI::cache()->get($cachekey); if (!is_null($object)) { diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index 10ff58b4b..d6a7384b6 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -391,6 +391,7 @@ class Receiver // Fetch the activity on Lemmy "Announce" messages (announces of activities) if (($type == 'as:Announce') && in_array($object_type, array_merge(self::ACTIVITY_TYPES, ['as:Delete', 'as:Undo', 'as:Update']))) { + Logger::debug('Fetch announced activity', ['object' => $object_id]); $data = Processor::fetchCachedActivity($object_id, $fetch_uid); if (!empty($data)) { $type = $object_type; @@ -590,6 +591,7 @@ class Receiver // Lemmy is announcing activities. // We are changing the announces into regular activities. if (($type == 'as:Announce') && in_array($object_data['type'] ?? '', array_merge(self::ACTIVITY_TYPES, ['as:Delete', 'as:Undo', 'as:Update']))) { + Logger::debug('Change type of announce to activity', ['type' => $object_data['type']]); $type = $object_data['type']; } @@ -727,11 +729,13 @@ class Receiver if (!Post::exists(['uri' => $object_data['id'], 'uid' => 0])) { $item = ActivityPub\Processor::createItem($object_data, $fetch_parents); if (empty($item)) { + Logger::debug('announced id was not created', ['id' => $object_data['id']]); return false; } $item['post-reason'] = Item::PR_ANNOUNCEMENT; ActivityPub\Processor::postItem($object_data, $item); + Logger::debug('Created announced id', ['id' => $object_data['id']]); } else { Logger::info('Announced id already exists', ['id' => $object_data['id']]); Queue::remove($object_data); @@ -744,6 +748,7 @@ class Receiver $announce_object_data['object_id'] = $object_data['object_id']; $announce_object_data['object_type'] = $object_data['object_type']; $announce_object_data['push'] = $push; + Logger::debug('Create announce activity', ['id' => $announce_object_data['id'], 'object_data' => $announce_object_data]); if (!empty($object_data['raw'])) { $announce_object_data['raw'] = $object_data['raw']; diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index 3758b0fe6..bd6002392 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -938,7 +938,7 @@ class OStatus break; default: - Logger::warning('Unsupported rel=' . $attribute['rel'] . ', href=' . $attribute['href'] . ', object-type=' . $item['object-type']); + Logger::notice('Unsupported rel=' . $attribute['rel'] . ', href=' . $attribute['href'] . ', object-type=' . $item['object-type']); } } } diff --git a/src/Security/OAuth.php b/src/Security/OAuth.php index a6f4fad80..3eaa022c5 100644 --- a/src/Security/OAuth.php +++ b/src/Security/OAuth.php @@ -96,7 +96,7 @@ class OAuth $token = DBA::selectFirst('application-view', ['uid', 'id', 'name', 'website', 'created_at', 'read', 'write', 'follow', 'push'], $condition); if (!DBA::isResult($token)) { - Logger::warning('Token not found', $condition); + Logger::notice('Token not found', $condition); return []; } Logger::debug('Token found', $token); diff --git a/src/Worker/Delivery.php b/src/Worker/Delivery.php index 786f71a66..32d488700 100644 --- a/src/Worker/Delivery.php +++ b/src/Worker/Delivery.php @@ -103,7 +103,7 @@ class Delivery DBA::close($itemdata); if (empty($target_item)) { - Logger::warning('Item ' . $target_id . "wasn't found. Quitting here."); + Logger::warning("No target item data. Quitting here.", ['id' => $target_id]); return; } From 9ca470cc943f90305048e7fc89fdab473a580ba0 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 31 Aug 2022 05:02:28 +0000 Subject: [PATCH 3/4] Reverted experimental change --- src/Database/DBStructure.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 2745f1cb8..d14e791e2 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -119,7 +119,7 @@ class DBStructure $tables = array_merge($tables, DBA::selectToArray( 'information_schema.tables', ['table_name'], - ['engine' => 'InnoDB', 'ROW_FORMAT' => ['COMPACT', 'REDUNDANT', 'COMPRESSED'], 'table_schema' => DBA::databaseName()] + ['engine' => 'InnoDB', 'ROW_FORMAT' => ['COMPACT', 'REDUNDANT'], 'table_schema' => DBA::databaseName()] )); if (!DBA::isResult($tables)) { From cc43b567cb8772d70a5b0c3a5ce169d5b6f25388 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 31 Aug 2022 19:03:37 +0000 Subject: [PATCH 4/4] Some changes after code review --- mod/tagger.php | 2 +- src/Core/Worker.php | 2 +- src/Model/Photo.php | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mod/tagger.php b/mod/tagger.php index f4f77c08e..e0d95ce66 100644 --- a/mod/tagger.php +++ b/mod/tagger.php @@ -51,7 +51,7 @@ function tagger_content(App $a) { $item_id = ((DI::args()->getArgc() > 1) ? trim(DI::args()->getArgv()[1]) : 0); - Logger::info('tagger: tag ' . $term . ' item ' . $item_id); + Logger::info('tagger: tag', ['term' => $term, 'item' => $item_id]); $item = Post::selectFirst([], ['id' => $item_id]); diff --git a/src/Core/Worker.php b/src/Core/Worker.php index 8abb8c178..f7ab2bc7c 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -104,7 +104,7 @@ class Worker foreach ($r as $entry) { // The work will be done if (!self::execute($entry)) { - Logger::warning('Process execution failed, quitting.'); + Logger::warning('Process execution failed, quitting.', ['entry' => $entry]); return; } diff --git a/src/Model/Photo.php b/src/Model/Photo.php index 287fc65ad..4d9ff4b6a 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -1095,7 +1095,7 @@ class Photo $r = self::store($image, $user['uid'], 0, $resource_id, $filename, $album, 0, self::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc); if (!$r) { - Logger::warning('Photo could not be stored'); + Logger::warning('Photo could not be stored', ['uid' => $user['uid'], 'resource_id' => $resource_id, 'filename' => $filename, 'album' => $album]); return []; } @@ -1182,7 +1182,7 @@ class Photo $r = self::store($image, $uid, 0, $resource_id, $filename, $album, 4, self::USER_AVATAR); if (!$r) { - logger::warning('profile image upload with scale 4 (300) failed'); + logger::warning('profile image upload with scale 4 (300) failed', ['uid' => $uid, 'resource_id' => $resource_id, 'filename' => $filename, 'album' => $album]); } if ($width > 80 || $height > 80) { @@ -1191,7 +1191,7 @@ class Photo $r = self::store($image, $uid, 0, $resource_id, $filename, $album, 5, self::USER_AVATAR); if (!$r) { - logger::warning('profile image upload with scale 5 (80) failed'); + logger::warning('profile image upload with scale 5 (80) failed', ['uid' => $uid, 'resource_id' => $resource_id, 'filename' => $filename, 'album' => $album]); } if ($width > 48 || $height > 48) { @@ -1200,7 +1200,7 @@ class Photo $r = self::store($image, $uid, 0, $resource_id, $filename, $album, 6, self::USER_AVATAR); if (!$r) { - logger::warning('profile image upload with scale 6 (48) failed'); + logger::warning('profile image upload with scale 6 (48) failed', ['uid' => $uid, 'resource_id' => $resource_id, 'filename' => $filename, 'album' => $album]); } logger::info('new profile image upload ended');