diff --git a/src/Core/Logger.php b/src/Core/Logger.php index 4e2575d1b..4c9bab76b 100644 --- a/src/Core/Logger.php +++ b/src/Core/Logger.php @@ -31,37 +31,6 @@ use Psr\Log\LogLevel; */ class Logger { - /** - * @see Logger::error() - * @deprecated since 2019.01 - */ - const WARNING = LogLevel::ERROR; - /** - * @see Logger::warning() - * @deprecated since 2019.01 - */ - const INFO = LogLevel::WARNING; - /** - * @see Logger::notice() - * @deprecated since 2019.01 - */ - const TRACE = LogLevel::NOTICE; - /** - * @see Logger::info() - * @deprecated since 2019.01 - */ - const DEBUG = LogLevel::INFO; - /** - * @see Logger::debug() - * @deprecated since 2019.01 - */ - const DATA = LogLevel::DEBUG; - /** - * @see Logger::debug() - * @deprecated since 2019.01 - */ - const ALL = LogLevel::DEBUG; - /** * @var LoggerInterface The default Logger type */ @@ -75,20 +44,6 @@ class Logger */ private static $type = self::TYPE_LOGGER; - /** - * @var array the legacy loglevels - * @deprecated 2019.03 use PSR-3 loglevels - * @see https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#5-psrlogloglevel - * - */ - public static $levels = [ - self::WARNING => 'Warning', - self::INFO => 'Info', - self::TRACE => 'Trace', - self::DEBUG => 'Debug', - self::DATA => 'Data', - ]; - /** * @return LoggerInterface */ @@ -254,20 +209,6 @@ class Logger self::getWorker()->debug($message, $context); } - /** - * Logs the given message at the given log level - * - * @param string $msg - * @param string $level - * - * @throws \Exception - * @deprecated since 2019.03 Use Logger::debug() Logger::info() , ... instead - */ - public static function log($msg, $level = LogLevel::INFO) - { - self::getWorker()->log($level, $msg); - } - /** * An alternative logger for development. * diff --git a/src/Core/System.php b/src/Core/System.php index 86e562f12..f680b6530 100644 --- a/src/Core/System.php +++ b/src/Core/System.php @@ -102,7 +102,7 @@ class System } if ($st) { - Logger::log('xml_status returning non_zero: ' . $st . " message=" . $message); + Logger::notice('xml_status returning non_zero: ' . $st . " message=" . $message); } header("Content-type: text/xml"); @@ -278,27 +278,27 @@ class System public static function isDirectoryUsable($directory, $check_writable = true) { if ($directory == '') { - Logger::log('Directory is empty. This shouldn\'t happen.', Logger::DEBUG); + Logger::info('Directory is empty. This shouldn\'t happen.'); return false; } if (!file_exists($directory)) { - Logger::log('Path "' . $directory . '" does not exist for user ' . static::getUser(), Logger::DEBUG); + Logger::info('Path "' . $directory . '" does not exist for user ' . static::getUser()); return false; } if (is_file($directory)) { - Logger::log('Path "' . $directory . '" is a file for user ' . static::getUser(), Logger::DEBUG); + Logger::info('Path "' . $directory . '" is a file for user ' . static::getUser()); return false; } if (!is_dir($directory)) { - Logger::log('Path "' . $directory . '" is not a directory for user ' . static::getUser(), Logger::DEBUG); + Logger::info('Path "' . $directory . '" is not a directory for user ' . static::getUser()); return false; } if ($check_writable && !is_writable($directory)) { - Logger::log('Path "' . $directory . '" is not writable for user ' . static::getUser(), Logger::DEBUG); + Logger::info('Path "' . $directory . '" is not writable for user ' . static::getUser()); return false; } diff --git a/src/Core/UserImport.php b/src/Core/UserImport.php index 67960fabd..fbc89ccf5 100644 --- a/src/Core/UserImport.php +++ b/src/Core/UserImport.php @@ -110,7 +110,7 @@ class UserImport */ public static function importAccount($file) { - Logger::log("Start user import from " . $file['tmp_name']); + Logger::notice("Start user import from " . $file['tmp_name']); /* STEPS 1. checks @@ -171,7 +171,7 @@ class UserImport // import user $r = self::dbImportAssoc('user', $account['user']); if ($r === false) { - Logger::log("uimport:insert user : ERROR : " . DBA::errorMessage(), Logger::INFO); + Logger::warning("uimport:insert user : ERROR : " . DBA::errorMessage()); notice(DI::l10n()->t("User creation error")); return; } @@ -210,7 +210,7 @@ class UserImport $contact['uid'] = $newuid; $r = self::dbImportAssoc('contact', $contact); if ($r === false) { - Logger::log("uimport:insert contact " . $contact['nick'] . "," . $contact['network'] . " : ERROR : " . DBA::errorMessage(), Logger::INFO); + Logger::warning("uimport:insert contact " . $contact['nick'] . "," . $contact['network'] . " : ERROR : " . DBA::errorMessage()); $errorcount++; } else { $contact['newid'] = self::lastInsertId(); @@ -224,7 +224,7 @@ class UserImport $group['uid'] = $newuid; $r = self::dbImportAssoc('group', $group); if ($r === false) { - Logger::log("uimport:insert group " . $group['name'] . " : ERROR : " . DBA::errorMessage(), Logger::INFO); + Logger::warning("uimport:insert group " . $group['name'] . " : ERROR : " . DBA::errorMessage()); } else { $group['newid'] = self::lastInsertId(); } @@ -249,7 +249,7 @@ class UserImport if ($import == 2) { $r = self::dbImportAssoc('group_member', $group_member); if ($r === false) { - Logger::log("uimport:insert group member " . $group_member['id'] . " : ERROR : " . DBA::errorMessage(), Logger::INFO); + Logger::warning("uimport:insert group member " . $group_member['id'] . " : ERROR : " . DBA::errorMessage()); } } } @@ -269,7 +269,7 @@ class UserImport $r = self::dbImportAssoc('profile', $profile); if ($r === false) { - Logger::log("uimport:insert profile: ERROR : " . DBA::errorMessage(), Logger::INFO); + Logger::warning("uimport:insert profile: ERROR : " . DBA::errorMessage()); notice(DI::l10n()->t("User profile creation error")); DBA::delete('user', ['uid' => $newuid]); DBA::delete('profile_field', ['uid' => $newuid]); @@ -308,7 +308,7 @@ class UserImport ); if ($r === false) { - Logger::log("uimport:insert photo " . $photo['resource-id'] . "," . $photo['scale'] . " : ERROR : " . DBA::errorMessage(), Logger::INFO); + Logger::warning("uimport:insert photo " . $photo['resource-id'] . "," . $photo['scale'] . " : ERROR : " . DBA::errorMessage()); } } @@ -316,7 +316,7 @@ class UserImport $pconfig['uid'] = $newuid; $r = self::dbImportAssoc('pconfig', $pconfig); if ($r === false) { - Logger::log("uimport:insert pconfig " . $pconfig['id'] . " : ERROR : " . DBA::errorMessage(), Logger::INFO); + Logger::warning("uimport:insert pconfig " . $pconfig['id'] . " : ERROR : " . DBA::errorMessage()); } } diff --git a/src/Model/Profile.php b/src/Model/Profile.php index bcd7d5497..9bbec24e6 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -219,7 +219,7 @@ class Profile { $profile = User::getOwnerDataByNick($nickname); if (empty($profile)) { - Logger::log('profile error: ' . DI::args()->getQueryString(), Logger::DEBUG); + Logger::info('profile error: ' . DI::args()->getQueryString()); return []; } @@ -706,27 +706,27 @@ class Profile // Try to find the public contact entry of the visitor. $cid = Contact::getIdForURL($my_url); if (!$cid) { - Logger::log('No contact record found for ' . $my_url, Logger::DEBUG); + Logger::info('No contact record found for ' . $my_url); return; } $contact = DBA::selectFirst('contact',['id', 'url'], ['id' => $cid]); if (DBA::isResult($contact) && remote_user() && remote_user() == $contact['id']) { - Logger::log('The visitor ' . $my_url . ' is already authenticated', Logger::DEBUG); + Logger::info('The visitor ' . $my_url . ' is already authenticated'); return; } // Avoid endless loops $cachekey = 'zrlInit:' . $my_url; if (DI::cache()->get($cachekey)) { - Logger::log('URL ' . $my_url . ' already tried to authenticate.', Logger::DEBUG); + Logger::info('URL ' . $my_url . ' already tried to authenticate.'); return; } else { DI::cache()->set($cachekey, true, Duration::MINUTE); } - Logger::log('Not authenticated. Invoking reverse magic-auth for ' . $my_url, Logger::DEBUG); + Logger::info('Not authenticated. Invoking reverse magic-auth for ' . $my_url); // Remove the "addr" parameter from the destination. It is later added as separate parameter again. $addr_request = 'addr=' . urlencode($addr); @@ -745,7 +745,7 @@ class Profile // We have to check if the remote server does understand /magic without invoking something $serverret = DI::httpClient()->get($basepath . '/magic'); if ($serverret->isSuccess()) { - Logger::log('Doing magic auth for visitor ' . $my_url . ' to ' . $magic_path, Logger::DEBUG); + Logger::info('Doing magic auth for visitor ' . $my_url . ' to ' . $magic_path); System::externalRedirect($magic_path); } } @@ -845,7 +845,7 @@ class Profile info(DI::l10n()->t('OpenWebAuth: %1$s welcomes %2$s', DI::baseUrl()->getHostname(), $visitor['name'])); - Logger::log('OpenWebAuth: auth success from ' . $visitor['addr'], Logger::DEBUG); + Logger::info('OpenWebAuth: auth success from ' . $visitor['addr']); } public static function zrl($s, $force = false) diff --git a/src/Model/PushSubscriber.php b/src/Model/PushSubscriber.php index f68393072..8593478de 100644 --- a/src/Model/PushSubscriber.php +++ b/src/Model/PushSubscriber.php @@ -64,7 +64,7 @@ class PushSubscriber $priority = $default_priority; } - Logger::log('Publish feed to ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' with priority ' . $priority, Logger::DEBUG); + Logger::info('Publish feed to ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' with priority ' . $priority); Worker::add($priority, 'PubSubPublish', (int)$subscriber['id']); } @@ -108,9 +108,9 @@ class PushSubscriber 'secret' => $hub_secret]; DBA::insert('push_subscriber', $fields); - Logger::log("Successfully subscribed [$hub_callback] for $nick"); + Logger::notice("Successfully subscribed [$hub_callback] for $nick"); } else { - Logger::log("Successfully unsubscribed [$hub_callback] for $nick"); + Logger::notice("Successfully unsubscribed [$hub_callback] for $nick"); // we do nothing here, since the row was already deleted } } @@ -136,10 +136,10 @@ class PushSubscriber if ($days > 60) { DBA::update('push_subscriber', ['push' => -1, 'next_try' => DBA::NULL_DATETIME], ['id' => $id]); - Logger::log('Delivery error: Subscription ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' is marked as ended.', Logger::DEBUG); + Logger::info('Delivery error: Subscription ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' is marked as ended.'); } else { DBA::update('push_subscriber', ['push' => 0, 'next_try' => DBA::NULL_DATETIME], ['id' => $id]); - Logger::log('Delivery error: Giving up ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' for now.', Logger::DEBUG); + Logger::info('Delivery error: Giving up ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' for now.'); } } else { // Calculate the delay until the next trial @@ -149,7 +149,7 @@ class PushSubscriber $retrial = $retrial + 1; DBA::update('push_subscriber', ['push' => $retrial, 'next_try' => $next], ['id' => $id]); - Logger::log('Delivery error: Next try (' . $retrial . ') ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' at ' . $next, Logger::DEBUG); + Logger::info('Delivery error: Next try (' . $retrial . ') ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' at ' . $next); } } @@ -170,7 +170,7 @@ class PushSubscriber // set last_update to the 'created' date of the last item, and reset push=0 $fields = ['push' => 0, 'next_try' => DBA::NULL_DATETIME, 'last_update' => $last_update]; DBA::update('push_subscriber', $fields, ['id' => $id]); - Logger::log('Subscriber ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' is marked as vital', Logger::DEBUG); + Logger::info('Subscriber ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' is marked as vital'); $parts = parse_url($subscriber['callback_url']); unset($parts['path']); diff --git a/src/Model/User.php b/src/Model/User.php index 794494342..65e64cb5c 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -979,7 +979,7 @@ class User $username_max_length = max(1, min(64, intval(DI::config()->get('system', 'username_max_length', 48)))); if ($username_min_length > $username_max_length) { - Logger::log(DI::l10n()->t('system.username_min_length (%s) and system.username_max_length (%s) are excluding each other, swapping values.', $username_min_length, $username_max_length), Logger::WARNING); + Logger::error(DI::l10n()->t('system.username_min_length (%s) and system.username_max_length (%s) are excluding each other, swapping values.', $username_min_length, $username_max_length)); $tmp = $username_min_length; $username_min_length = $username_max_length; $username_max_length = $tmp; diff --git a/src/Object/Post.php b/src/Object/Post.php index 7a8e67404..815f0d9ce 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -594,10 +594,10 @@ class Post { $item_id = $item->getId(); if (!$item_id) { - Logger::log('[ERROR] Post::addChild : Item has no ID!!', Logger::DEBUG); + Logger::info('[ERROR] Post::addChild : Item has no ID!!'); return false; } elseif ($this->getChild($item->getId())) { - Logger::log('[WARN] Post::addChild : Item already exists (' . $item->getId() . ').', Logger::DEBUG); + Logger::info('[WARN] Post::addChild : Item already exists (' . $item->getId() . ').'); return false; } @@ -696,7 +696,7 @@ class Post return true; } } - Logger::log('[WARN] Item::removeChild : Item is not a child (' . $id . ').', Logger::DEBUG); + Logger::info('[WARN] Item::removeChild : Item is not a child (' . $id . ').'); return false; } @@ -760,7 +760,7 @@ class Post public function getDataValue($name) { if (!isset($this->data[$name])) { - // Logger::log('[ERROR] Item::getDataValue : Item has no value name "'. $name .'".', Logger::DEBUG); + // Logger::info('[ERROR] Item::getDataValue : Item has no value name "'. $name .'".'); return false; } @@ -777,7 +777,7 @@ class Post private function setTemplate($name) { if (empty($this->available_templates[$name])) { - Logger::log('[ERROR] Item::setTemplate : Template not available ("' . $name . '").', Logger::DEBUG); + Logger::info('[ERROR] Item::setTemplate : Template not available ("' . $name . '").'); return false; } diff --git a/src/Object/Thread.php b/src/Object/Thread.php index a2504a2ad..666210c39 100644 --- a/src/Object/Thread.php +++ b/src/Object/Thread.php @@ -95,7 +95,7 @@ class Thread $this->writable = $writable; break; default: - Logger::log('[ERROR] Conversation::setMode : Unhandled mode ('. $mode .').', Logger::DEBUG); + Logger::info('[ERROR] Conversation::setMode : Unhandled mode ('. $mode .').'); return false; break; } @@ -156,12 +156,12 @@ class Thread $item_id = $item->getId(); if (!$item_id) { - Logger::log('[ERROR] Conversation::addThread : Item has no ID!!', Logger::DEBUG); + Logger::info('[ERROR] Conversation::addThread : Item has no ID!!'); return false; } if ($this->getParent($item->getId())) { - Logger::log('[WARN] Conversation::addThread : Thread already exists ('. $item->getId() .').', Logger::DEBUG); + Logger::info('[WARN] Conversation::addThread : Thread already exists ('. $item->getId() .').'); return false; } @@ -169,12 +169,12 @@ class Thread * Only add will be displayed */ if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) { - Logger::log('[WARN] Conversation::addThread : Thread is a mail ('. $item->getId() .').', Logger::DEBUG); + Logger::info('[WARN] Conversation::addThread : Thread is a mail ('. $item->getId() .').'); return false; } if ($item->getDataValue('verb') === Activity::LIKE || $item->getDataValue('verb') === Activity::DISLIKE) { - Logger::log('[WARN] Conversation::addThread : Thread is a (dis)like ('. $item->getId() .').', Logger::DEBUG); + Logger::info('[WARN] Conversation::addThread : Thread is a (dis)like ('. $item->getId() .').'); return false; } @@ -208,7 +208,7 @@ class Thread $item_data = $item->getTemplateData($conv_responses, $formSecurityToken); if (!$item_data) { - Logger::log('[ERROR] Conversation::getTemplateData : Failed to get item template data ('. $item->getId() .').', Logger::DEBUG); + Logger::info('[ERROR] Conversation::getTemplateData : Failed to get item template data ('. $item->getId() .').'); return false; } $result[] = $item_data; diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index 34c509870..495e0271d 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -117,28 +117,28 @@ class Receiver if (LDSignature::isSigned($activity)) { $ld_signer = LDSignature::getSigner($activity); if (empty($ld_signer)) { - Logger::log('Invalid JSON-LD signature from ' . $actor, Logger::DEBUG); + Logger::info('Invalid JSON-LD signature from ' . $actor); } elseif ($ld_signer != $http_signer) { $signer[] = $ld_signer; } if (!empty($ld_signer && ($actor == $http_signer))) { - Logger::log('The HTTP and the JSON-LD signature belong to ' . $ld_signer, Logger::DEBUG); + Logger::info('The HTTP and the JSON-LD signature belong to ' . $ld_signer); $trust_source = true; } elseif (!empty($ld_signer)) { - Logger::log('JSON-LD signature is signed by ' . $ld_signer, Logger::DEBUG); + Logger::info('JSON-LD signature is signed by ' . $ld_signer); $trust_source = true; } elseif ($actor == $http_signer) { - Logger::log('Bad JSON-LD signature, but HTTP signer fits the actor.', Logger::DEBUG); + Logger::info('Bad JSON-LD signature, but HTTP signer fits the actor.'); $trust_source = true; } else { - Logger::log('Invalid JSON-LD signature and the HTTP signer is different.', Logger::DEBUG); + Logger::info('Invalid JSON-LD signature and the HTTP signer is different.'); $trust_source = false; } } elseif ($actor == $http_signer) { - Logger::log('Trusting post without JSON-LD signature, The actor fits the HTTP signer.', Logger::DEBUG); + Logger::info('Trusting post without JSON-LD signature, The actor fits the HTTP signer.'); $trust_source = true; } else { - Logger::log('No JSON-LD signature, different actor.', Logger::DEBUG); + Logger::info('No JSON-LD signature, different actor.'); $trust_source = false; } @@ -310,7 +310,7 @@ class Receiver $object_id = JsonLD::fetchElement($activity, 'as:object', '@id'); if (empty($object_id)) { - Logger::log('No object found', Logger::DEBUG); + Logger::info('No object found'); return []; } @@ -327,7 +327,7 @@ class Receiver // Always fetch on "Announce" $object_data = self::fetchObject($object_id, $activity['as:object'], $trust_source && ($type != 'as:Announce'), $uid); if (empty($object_data)) { - Logger::log("Object data couldn't be processed", Logger::DEBUG); + Logger::info("Object data couldn't be processed"); return []; } @@ -401,7 +401,7 @@ class Receiver } } - Logger::log('Processing ' . $object_data['type'] . ' ' . $object_data['object_type'] . ' ' . $object_data['id'], Logger::DEBUG); + Logger::info('Processing ' . $object_data['type'] . ' ' . $object_data['object_type'] . ' ' . $object_data['id']); return $object_data; } @@ -606,7 +606,7 @@ class Receiver break; default: - Logger::log('Unknown activity: ' . $type . ' ' . $object_data['object_type'], Logger::DEBUG); + Logger::info('Unknown activity: ' . $type . ' ' . $object_data['object_type']); break; } } @@ -921,16 +921,16 @@ class Receiver $data = ActivityPub::fetchContent($object_id, $uid); if (!empty($data)) { $object = JsonLD::compact($data); - Logger::log('Fetched content for ' . $object_id, Logger::DEBUG); + Logger::info('Fetched content for ' . $object_id); } else { - Logger::log('Empty content for ' . $object_id . ', check if content is available locally.', Logger::DEBUG); + Logger::info('Empty content for ' . $object_id . ', check if content is available locally.'); $item = Post::selectFirst(Item::DELIVER_FIELDLIST, ['uri' => $object_id]); if (!DBA::isResult($item)) { - Logger::log('Object with url ' . $object_id . ' was not found locally.', Logger::DEBUG); + Logger::info('Object with url ' . $object_id . ' was not found locally.'); return false; } - Logger::log('Using already stored item for url ' . $object_id, Logger::DEBUG); + Logger::info('Using already stored item for url ' . $object_id); $data = ActivityPub\Transmitter::createNote($item); $object = JsonLD::compact($data); } @@ -946,7 +946,7 @@ class Receiver return false; } } else { - Logger::log('Using original object for url ' . $object_id, Logger::DEBUG); + Logger::info('Using original object for url ' . $object_id); } $type = JsonLD::fetchElement($object, '@type'); @@ -973,7 +973,7 @@ class Receiver return self::fetchObject($object_id, [], false, $uid); } - Logger::log('Unhandled object type: ' . $type, Logger::DEBUG); + Logger::info('Unhandled object type: ' . $type); return false; } diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index 238aa3c16..44b0463b0 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -1796,7 +1796,7 @@ class Transmitter $signed = LDSignature::sign($data, $owner); - Logger::log('Deliver profile deletion for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', Logger::DEBUG); + Logger::info('Deliver profile deletion for user ' . $uid . ' to ' . $inbox . ' via ActivityPub'); return HTTPSignature::transmit($signed, $inbox, $uid); } @@ -1825,7 +1825,7 @@ class Transmitter $signed = LDSignature::sign($data, $owner); - Logger::log('Deliver profile relocation for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', Logger::DEBUG); + Logger::info('Deliver profile relocation for user ' . $uid . ' to ' . $inbox . ' via ActivityPub'); return HTTPSignature::transmit($signed, $inbox, $uid); } @@ -1864,7 +1864,7 @@ class Transmitter $signed = LDSignature::sign($data, $owner); - Logger::log('Deliver profile deletion for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', Logger::DEBUG); + Logger::info('Deliver profile deletion for user ' . $uid . ' to ' . $inbox . ' via ActivityPub'); return HTTPSignature::transmit($signed, $inbox, $uid); } @@ -1896,7 +1896,7 @@ class Transmitter $signed = LDSignature::sign($data, $owner); - Logger::log('Deliver profile update for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', Logger::DEBUG); + Logger::info('Deliver profile update for user ' . $uid . ' to ' . $inbox . ' via ActivityPub'); return HTTPSignature::transmit($signed, $inbox, $uid); } @@ -1933,7 +1933,7 @@ class Transmitter 'instrument' => self::getService(), 'to' => [$profile['url']]]; - Logger::log('Sending activity ' . $activity . ' to ' . $target . ' for user ' . $uid, Logger::DEBUG); + Logger::info('Sending activity ' . $activity . ' to ' . $target . ' for user ' . $uid); $signed = LDSignature::sign($data, $owner); return HTTPSignature::transmit($signed, $profile['inbox'], $uid); @@ -1972,7 +1972,7 @@ class Transmitter $condition = ['verb' => Activity::FOLLOW, 'uid' => 0, 'parent-uri' => $object, 'author-id' => Contact::getPublicIdByUserId($uid)]; if (Post::exists($condition)) { - Logger::log('Follow for ' . $object . ' for user ' . $uid . ' does already exist.', Logger::DEBUG); + Logger::info('Follow for ' . $object . ' for user ' . $uid . ' does already exist.'); return false; } @@ -1986,7 +1986,7 @@ class Transmitter 'instrument' => self::getService(), 'to' => [$profile['url']]]; - Logger::log('Sending follow ' . $object . ' to ' . $target . ' for user ' . $uid, Logger::DEBUG); + Logger::info('Sending follow ' . $object . ' to ' . $target . ' for user ' . $uid); $signed = LDSignature::sign($data, $owner); return HTTPSignature::transmit($signed, $profile['inbox'], $uid); @@ -2103,7 +2103,7 @@ class Transmitter 'instrument' => self::getService(), 'to' => [$profile['url']]]; - Logger::log('Sending undo to ' . $target . ' for user ' . $uid . ' with id ' . $id, Logger::DEBUG); + Logger::info('Sending undo to ' . $target . ' for user ' . $uid . ' with id ' . $id); $signed = LDSignature::sign($data, $owner); return HTTPSignature::transmit($signed, $profile['inbox'], $uid); diff --git a/src/Protocol/Email.php b/src/Protocol/Email.php index e351d5c70..f915e9f74 100644 --- a/src/Protocol/Email.php +++ b/src/Protocol/Email.php @@ -50,12 +50,12 @@ class Email $errors = imap_errors(); if (!empty($errors)) { - Logger::log('IMAP Errors occured: ' . json_encode($errors)); + Logger::notice('IMAP Errors occured', ['errora' => $errors]); } $alerts = imap_alerts(); if (!empty($alerts)) { - Logger::log('IMAP Alerts occured: ' . json_encode($alerts)); + Logger::notice('IMAP Alerts occured: ', ['alerts' => $alerts]); } return $mbox; @@ -77,21 +77,21 @@ class Email if (!$search1) { $search1 = []; } else { - Logger::log("Found mails from ".$email_addr, Logger::DEBUG); + Logger::notice("Found mails from ".$email_addr); } $search2 = @imap_search($mbox, 'UNDELETED TO "' . $email_addr . '"', SE_UID); if (!$search2) { $search2 = []; } else { - Logger::log("Found mails to ".$email_addr, Logger::DEBUG); + Logger::notice("Found mails to ".$email_addr); } $search3 = @imap_search($mbox, 'UNDELETED CC "' . $email_addr . '"', SE_UID); if (!$search3) { $search3 = []; } else { - Logger::log("Found mails cc ".$email_addr, Logger::DEBUG); + Logger::notice("Found mails cc ".$email_addr); } $res = array_unique(array_merge($search1, $search2, $search3)); @@ -396,7 +396,7 @@ class Email //$message = '' . $html . ''; //$message = html2plain($html); - Logger::log('notifier: email delivery to ' . $addr); + Logger::notice('notifier: email delivery to ' . $addr); mail($addr, $subject, $body, $headers); } diff --git a/src/Worker/Delivery.php b/src/Worker/Delivery.php index 36d576cff..ea18370cd 100644 --- a/src/Worker/Delivery.php +++ b/src/Worker/Delivery.php @@ -105,12 +105,12 @@ class Delivery DBA::close($itemdata); if (empty($target_item)) { - Logger::log('Item ' . $target_id . "wasn't found. Quitting here."); + Logger::notice('Item ' . $target_id . "wasn't found. Quitting here."); return; } if (empty($parent)) { - Logger::log('Parent ' . $parent_id . ' for item ' . $target_id . "wasn't found. Quitting here."); + Logger::notice('Parent ' . $parent_id . ' for item ' . $target_id . "wasn't found. Quitting here."); self::setFailedQueue($cmd, $target_item); return; } @@ -120,7 +120,7 @@ class Delivery } elseif (!empty($target_item['uid'])) { $uid = $target_item['uid']; } else { - Logger::log('Only public users for item ' . $target_id, Logger::DEBUG); + Logger::info('Only public users for item ' . $target_id); self::setFailedQueue($cmd, $target_item); return; } @@ -169,7 +169,7 @@ class Delivery */ if (!$top_level && ($parent['wall'] == 0) && stristr($target_item['uri'], $localhost)) { - Logger::log('Followup ' . $target_item["guid"], Logger::DEBUG); + Logger::info('Followup ' . $target_item["guid"]); // local followup to remote post $followup = true; } @@ -419,22 +419,22 @@ class Delivery $deliver_status = Diaspora::sendAccountMigration($owner, $contact, $owner['uid']); } elseif ($target_item['deleted'] && (($target_item['uri'] === $target_item['parent-uri']) || $followup)) { // top-level retraction - Logger::log('diaspora retract: ' . $loc); + Logger::notice('diaspora retract: ' . $loc); $deliver_status = Diaspora::sendRetraction($target_item, $owner, $contact, $public_message); } elseif ($followup) { // send comments and likes to owner to relay - Logger::log('diaspora followup: ' . $loc); + Logger::notice('diaspora followup: ' . $loc); $deliver_status = Diaspora::sendFollowup($target_item, $owner, $contact, $public_message); } elseif ($target_item['uri'] !== $target_item['parent-uri']) { // we are the relay - send comments, likes and relayable_retractions to our conversants - Logger::log('diaspora relay: ' . $loc); + Logger::notice('diaspora relay: ' . $loc); $deliver_status = Diaspora::sendRelay($target_item, $owner, $contact, $public_message); } elseif ($top_level && !$walltowall) { // currently no workable solution for sending walltowall - Logger::log('diaspora status: ' . $loc); + Logger::notice('diaspora status: ' . $loc); $deliver_status = Diaspora::sendStatus($target_item, $owner, $contact, $public_message); } else { - Logger::log('Unknown mode ' . $cmd . ' for ' . $loc); + Logger::notice('Unknown mode ' . $cmd . ' for ' . $loc); return; } diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index 6d7a7050b..0a77e6386 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -296,7 +296,7 @@ class Notifier $push_notify = false; } - Logger::log('Notify ' . $target_item["guid"] .' via PuSH: ' . ($push_notify ? "Yes":"No"), Logger::DEBUG); + Logger::info('Notify ' . $target_item["guid"] .' via PuSH: ' . ($push_notify ? "Yes":"No")); } elseif ($exclusive_delivery) { $followup = true; @@ -315,7 +315,7 @@ class Notifier // don't send deletions onward for other people's stuff if ($target_item['deleted'] && !intval($target_item['wall'])) { - Logger::log('Ignoring delete notification for non-wall item'); + Logger::notice('Ignoring delete notification for non-wall item'); return; } @@ -385,7 +385,7 @@ class Notifier if (($thr_parent && ($thr_parent['network'] == Protocol::OSTATUS)) || ($parent['network'] == Protocol::OSTATUS)) { $diaspora_delivery = false; - Logger::log('Some parent is OStatus for '.$target_item["guid"]." - Author: ".$thr_parent['author-id']." - Owner: ".$thr_parent['owner-id'], Logger::DEBUG); + Logger::info('Some parent is OStatus for '.$target_item["guid"]." - Author: ".$thr_parent['author-id']." - Owner: ".$thr_parent['owner-id']); // Send a salmon to the parent author $probed_contact = DBA::selectFirst('contact', ['url', 'notify'], ['id' => $thr_parent['author-id']]); @@ -490,7 +490,7 @@ class Notifier $delivery_queue_count += self::deliverOStatus($target_id, $target_item, $owner, $url_recipients, $public_message, $push_notify); if (!empty($target_item)) { - Logger::log('Calling hooks for ' . $cmd . ' ' . $target_id, Logger::DEBUG); + Logger::info('Calling hooks for ' . $cmd . ' ' . $target_id); Hook::fork($a->getQueueValue('priority'), 'notifier_normal', $target_item); @@ -767,12 +767,12 @@ class Notifier $relay_inboxes = ActivityPub\Transmitter::addRelayServerInboxes(); } - Logger::log('Origin item ' . $target_item['id'] . ' with URL ' . $target_item['uri'] . ' will be distributed.', Logger::DEBUG); + Logger::info('Origin item ' . $target_item['id'] . ' with URL ' . $target_item['uri'] . ' will be distributed.'); } elseif (Item::isForumPost($target_item, $owner)) { $inboxes = ActivityPub\Transmitter::fetchTargetInboxes($target_item, $uid, false, 0, true); - Logger::log('Forum item ' . $target_item['id'] . ' with URL ' . $target_item['uri'] . ' will be distributed.', Logger::DEBUG); + Logger::info('Forum item ' . $target_item['id'] . ' with URL ' . $target_item['uri'] . ' will be distributed.'); } elseif (!DBA::exists('conversation', ['item-uri' => $target_item['uri'], 'protocol' => Conversation::PARCEL_ACTIVITYPUB])) { - Logger::log('Remote item ' . $target_item['id'] . ' with URL ' . $target_item['uri'] . ' is no AP post. It will not be distributed.', Logger::DEBUG); + Logger::info('Remote item ' . $target_item['id'] . ' with URL ' . $target_item['uri'] . ' is no AP post. It will not be distributed.'); return ['count' => 0, 'contacts' => []]; } elseif ($parent['origin']) { // Remote items are transmitted via the personal inboxes. @@ -784,11 +784,11 @@ class Notifier $relay_inboxes = ActivityPub\Transmitter::addRelayServerInboxes([]); } - Logger::log('Remote item ' . $target_item['id'] . ' with URL ' . $target_item['uri'] . ' will be distributed.', Logger::DEBUG); + Logger::info('Remote item ' . $target_item['id'] . ' with URL ' . $target_item['uri'] . ' will be distributed.'); } if (empty($inboxes) && empty($relay_inboxes)) { - Logger::log('No inboxes found for item ' . $target_item['id'] . ' with URL ' . $target_item['uri'] . '. It will not be distributed.', Logger::DEBUG); + Logger::info('No inboxes found for item ' . $target_item['id'] . ' with URL ' . $target_item['uri'] . '. It will not be distributed.'); return ['count' => 0, 'contacts' => []]; } diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php index 6d05e6cdc..1b5fdaa34 100644 --- a/src/Worker/OnePoll.php +++ b/src/Worker/OnePoll.php @@ -231,7 +231,7 @@ class OnePoll $metas = Email::messageMeta($mbox, implode(',', $msgs)); if (count($metas) != count($msgs)) { - Logger::log("for " . $mailconf['user'] . " there are ". count($msgs) . " messages but received " . count($metas) . " metas", Logger::DEBUG); + Logger::info("for " . $mailconf['user'] . " there are ". count($msgs) . " messages but received " . count($metas) . " metas"); } else { $msgs = array_combine($msgs, $metas); @@ -253,7 +253,7 @@ class OnePoll $condition = ['uid' => $importer_uid, 'uri' => $datarray['uri']]; $item = Post::selectFirst($fields, $condition); if (DBA::isResult($item)) { - Logger::log("Mail: Seen before ".$msg_uid." for ".$mailconf['user']." UID: ".$importer_uid." URI: ".$datarray['uri'],Logger::DEBUG); + Logger::info("Mail: Seen before ".$msg_uid." for ".$mailconf['user']." UID: ".$importer_uid." URI: ".$datarray['uri']); // Only delete when mails aren't automatically moved or deleted if (($mailconf['action'] != 1) && ($mailconf['action'] != 3)) @@ -264,18 +264,18 @@ class OnePoll switch ($mailconf['action']) { case 0: - Logger::log("Mail: Seen before ".$msg_uid." for ".$mailconf['user'].". Doing nothing.", Logger::DEBUG); + Logger::info("Mail: Seen before ".$msg_uid." for ".$mailconf['user'].". Doing nothing."); break; case 1: - Logger::log("Mail: Deleting ".$msg_uid." for ".$mailconf['user']); + Logger::notice("Mail: Deleting ".$msg_uid." for ".$mailconf['user']); imap_delete($mbox, $msg_uid, FT_UID); break; case 2: - Logger::log("Mail: Mark as seen ".$msg_uid." for ".$mailconf['user']); + Logger::notice("Mail: Mark as seen ".$msg_uid." for ".$mailconf['user']); imap_setflag_full($mbox, $msg_uid, "\\Seen", ST_UID); break; case 3: - Logger::log("Mail: Moving ".$msg_uid." to ".$mailconf['movetofolder']." for ".$mailconf['user']); + Logger::notice("Mail: Moving ".$msg_uid." to ".$mailconf['movetofolder']." for ".$mailconf['user']); imap_setflag_full($mbox, $msg_uid, "\\Seen", ST_UID); if ($mailconf['movetofolder'] != "") { imap_mail_move($mbox, $msg_uid, $mailconf['movetofolder'], FT_UID); @@ -387,28 +387,28 @@ class OnePoll $datarray = Email::getMessage($mbox, $msg_uid, $reply, $datarray); if (empty($datarray['body'])) { - Logger::log("Mail: can't fetch msg ".$msg_uid." for ".$mailconf['user']); + Logger::notice("Mail: can't fetch msg ".$msg_uid." for ".$mailconf['user']); continue; } - Logger::log("Mail: Importing ".$msg_uid." for ".$mailconf['user']); + Logger::notice("Mail: Importing ".$msg_uid." for ".$mailconf['user']); Item::insert($datarray); switch ($mailconf['action']) { case 0: - Logger::log("Mail: Seen before ".$msg_uid." for ".$mailconf['user'].". Doing nothing.", Logger::DEBUG); + Logger::info("Mail: Seen before ".$msg_uid." for ".$mailconf['user'].". Doing nothing."); break; case 1: - Logger::log("Mail: Deleting ".$msg_uid." for ".$mailconf['user']); + Logger::notice("Mail: Deleting ".$msg_uid." for ".$mailconf['user']); imap_delete($mbox, $msg_uid, FT_UID); break; case 2: - Logger::log("Mail: Mark as seen ".$msg_uid." for ".$mailconf['user']); + Logger::notice("Mail: Mark as seen ".$msg_uid." for ".$mailconf['user']); imap_setflag_full($mbox, $msg_uid, "\\Seen", ST_UID); break; case 3: - Logger::log("Mail: Moving ".$msg_uid." to ".$mailconf['movetofolder']." for ".$mailconf['user']); + Logger::notice("Mail: Moving ".$msg_uid." to ".$mailconf['movetofolder']." for ".$mailconf['user']); imap_setflag_full($mbox, $msg_uid, "\\Seen", ST_UID); if ($mailconf['movetofolder'] != "") { imap_mail_move($mbox, $msg_uid, $mailconf['movetofolder'], FT_UID);