mirror of
https://github.com/friendica/friendica
synced 2025-02-07 06:18:50 +00:00
Replace Logger with DI::logger() in Core classes
This commit is contained in:
parent
8c89c37775
commit
e3cf6b9c54
6 changed files with 43 additions and 43 deletions
|
@ -117,7 +117,7 @@ class Addon
|
|||
{
|
||||
$addon = Strings::sanitizeFilePathItem($addon);
|
||||
|
||||
Logger::debug("Addon {addon}: {action}", ['action' => 'uninstall', 'addon' => $addon]);
|
||||
DI::logger()->debug("Addon {addon}: {action}", ['action' => 'uninstall', 'addon' => $addon]);
|
||||
DI::config()->delete('addons', $addon);
|
||||
|
||||
@include_once('addon/' . $addon . '/' . $addon . '.php');
|
||||
|
@ -150,7 +150,7 @@ class Addon
|
|||
return false;
|
||||
}
|
||||
|
||||
Logger::debug("Addon {addon}: {action}", ['action' => 'install', 'addon' => $addon]);
|
||||
DI::logger()->debug("Addon {addon}: {action}", ['action' => 'install', 'addon' => $addon]);
|
||||
$t = @filemtime($addon_file_path);
|
||||
@include_once($addon_file_path);
|
||||
if (function_exists($addon . '_install')) {
|
||||
|
@ -189,7 +189,7 @@ class Addon
|
|||
continue;
|
||||
}
|
||||
|
||||
Logger::debug("Addon {addon}: {action}", ['action' => 'reload', 'addon' => $name]);
|
||||
DI::logger()->debug("Addon {addon}: {action}", ['action' => 'reload', 'addon' => $name]);
|
||||
|
||||
self::uninstall($name);
|
||||
self::install($name);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
namespace Friendica\Core;
|
||||
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
|
@ -123,7 +124,7 @@ class Protocol
|
|||
|
||||
if ($protocol == self::DIASPORA) {
|
||||
$contact = Diaspora::sendShare($owner, $contact);
|
||||
Logger::notice('share returns: ' . $contact);
|
||||
DI::logger()->notice('share returns: ' . $contact);
|
||||
} elseif (in_array($protocol, [self::ACTIVITYPUB, self::DFRN])) {
|
||||
$activity_id = ActivityPub\Transmitter::activityIDFromContact($contact['id']);
|
||||
if (empty($activity_id)) {
|
||||
|
@ -132,7 +133,7 @@ class Protocol
|
|||
}
|
||||
|
||||
$success = ActivityPub\Transmitter::sendActivity('Follow', $contact['url'], $owner['uid'], $activity_id);
|
||||
Logger::notice('Follow returns: ' . $success);
|
||||
DI::logger()->notice('Follow returns: ' . $success);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -150,7 +151,7 @@ class Protocol
|
|||
public static function unfollow(array $contact, array $owner): ?bool
|
||||
{
|
||||
if (empty($contact['network'])) {
|
||||
Logger::notice('Contact has got no network, we quit here', ['id' => $contact['id']]);
|
||||
DI::logger()->notice('Contact has got no network, we quit here', ['id' => $contact['id']]);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ use Friendica\Network\HTTPException;
|
|||
use Friendica\Object\Search\ContactResult;
|
||||
use Friendica\Object\Search\ResultList;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Strings;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
|
||||
/**
|
||||
|
@ -160,7 +159,7 @@ class Search
|
|||
*/
|
||||
public static function getContactsFromLocalDirectory(string $search, int $type = self::TYPE_ALL, int $start = 0, int $itemPage = 80): ResultList
|
||||
{
|
||||
Logger::info('Searching', ['search' => $search, 'type' => $type, 'start' => $start, 'itempage' => $itemPage]);
|
||||
DI::logger()->info('Searching', ['search' => $search, 'type' => $type, 'start' => $start, 'itempage' => $itemPage]);
|
||||
|
||||
$contacts = Contact::searchByName($search, $type == self::TYPE_GROUP ? 'community' : '', true);
|
||||
|
||||
|
@ -200,7 +199,7 @@ class Search
|
|||
*/
|
||||
public static function searchContact(string $search, string $mode, int $page = 1): array
|
||||
{
|
||||
Logger::info('Searching', ['search' => $search, 'mode' => $mode, 'page' => $page]);
|
||||
DI::logger()->info('Searching', ['search' => $search, 'mode' => $mode, 'page' => $page]);
|
||||
|
||||
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
|
||||
return [];
|
||||
|
@ -223,7 +222,7 @@ class Search
|
|||
try {
|
||||
$curlResult = DI::httpClient()->get(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), HttpClientAccept::JSON, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTDISCOVER]);
|
||||
} catch (\Throwable $th) {
|
||||
Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
DI::logger()->notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
return [];
|
||||
}
|
||||
if ($curlResult->isSuccess()) {
|
||||
|
|
|
@ -322,7 +322,7 @@ class System
|
|||
}
|
||||
|
||||
if ($status) {
|
||||
Logger::notice('xml_status returning non_zero: ' . $status . " message=" . $message);
|
||||
DI::logger()->notice('xml_status returning non_zero: ' . $status . " message=" . $message);
|
||||
}
|
||||
|
||||
self::httpExit(XML::fromArray(['result' => $result]), Response::TYPE_XML);
|
||||
|
@ -340,7 +340,7 @@ class System
|
|||
public static function httpError($httpCode, $message = '', $content = '')
|
||||
{
|
||||
if ($httpCode >= 400) {
|
||||
Logger::debug('Exit with error', ['code' => $httpCode, 'message' => $message, 'method' => DI::args()->getMethod(), 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']);
|
||||
DI::logger()->debug('Exit with error', ['code' => $httpCode, 'message' => $message, 'method' => DI::args()->getMethod(), 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']);
|
||||
}
|
||||
DI::apiResponse()->setStatus($httpCode, $message);
|
||||
|
||||
|
@ -373,7 +373,7 @@ class System
|
|||
public static function jsonError($httpCode, $content, $content_type = 'application/json')
|
||||
{
|
||||
if ($httpCode >= 400) {
|
||||
Logger::debug('Exit with error', ['code' => $httpCode, 'content_type' => $content_type, 'method' => DI::args()->getMethod(), 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']);
|
||||
DI::logger()->debug('Exit with error', ['code' => $httpCode, 'content_type' => $content_type, 'method' => DI::args()->getMethod(), 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']);
|
||||
}
|
||||
DI::apiResponse()->setStatus($httpCode);
|
||||
self::jsonExit($content, $content_type);
|
||||
|
@ -520,7 +520,7 @@ class System
|
|||
public static function externalRedirect($url, $code = 302)
|
||||
{
|
||||
if (empty(parse_url($url, PHP_URL_SCHEME))) {
|
||||
Logger::warning('No fully qualified URL provided', ['url' => $url]);
|
||||
DI::logger()->warning('No fully qualified URL provided', ['url' => $url]);
|
||||
DI::baseUrl()->redirect($url);
|
||||
}
|
||||
|
||||
|
@ -564,27 +564,27 @@ class System
|
|||
private static function isDirectoryUsable(string $directory): bool
|
||||
{
|
||||
if (empty($directory)) {
|
||||
Logger::warning('Directory is empty. This shouldn\'t happen.');
|
||||
DI::logger()->warning('Directory is empty. This shouldn\'t happen.');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!file_exists($directory)) {
|
||||
Logger::info('Path does not exist', ['directory' => $directory, 'user' => static::getUser()]);
|
||||
DI::logger()->info('Path does not exist', ['directory' => $directory, 'user' => static::getUser()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_file($directory)) {
|
||||
Logger::warning('Path is a file', ['directory' => $directory, 'user' => static::getUser()]);
|
||||
DI::logger()->warning('Path is a file', ['directory' => $directory, 'user' => static::getUser()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_dir($directory)) {
|
||||
Logger::warning('Path is not a directory', ['directory' => $directory, 'user' => static::getUser()]);
|
||||
DI::logger()->warning('Path is not a directory', ['directory' => $directory, 'user' => static::getUser()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_writable($directory)) {
|
||||
Logger::warning('Path is not writable', ['directory' => $directory, 'user' => static::getUser()]);
|
||||
DI::logger()->warning('Path is not writable', ['directory' => $directory, 'user' => static::getUser()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ class Theme
|
|||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Logger::error('Theme installation failed', ['theme' => $theme, 'error' => $e->getMessage()]);
|
||||
DI::logger()->error('Theme installation failed', ['theme' => $theme, 'error' => $e->getMessage()]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ class Update
|
|||
// If the Lock is acquired, never release it automatically to avoid double updates
|
||||
if (DI::lock()->acquire('dbupdate', 0, Cache\Enum\Duration::INFINITE)) {
|
||||
|
||||
Logger::notice('Update starting.', ['from' => $stored, 'to' => $current]);
|
||||
DI::logger()->notice('Update starting.', ['from' => $stored, 'to' => $current]);
|
||||
|
||||
// Checks if the build changed during Lock acquiring (so no double update occurs)
|
||||
$retryBuild = DI::config()->get('system', 'build');
|
||||
|
@ -192,7 +192,7 @@ class Update
|
|||
}
|
||||
|
||||
if ($retryBuild != $build) {
|
||||
Logger::notice('Update already done.', ['from' => $build, 'retry' => $retryBuild, 'to' => $current]);
|
||||
DI::logger()->notice('Update already done.', ['from' => $build, 'retry' => $retryBuild, 'to' => $current]);
|
||||
DI::lock()->release('dbupdate');
|
||||
return '';
|
||||
}
|
||||
|
@ -202,12 +202,12 @@ class Update
|
|||
|
||||
// run the pre_update_nnnn functions in update.php
|
||||
for ($version = $stored + 1; $version <= $current; $version++) {
|
||||
Logger::notice('Execute pre update.', ['version' => $version]);
|
||||
DI::logger()->notice('Execute pre update.', ['version' => $version]);
|
||||
DI::config()->set('system', 'maintenance_reason', DI::l10n()->t('%s: executing pre update %d',
|
||||
DateTimeFormat::utcNow() . ' ' . date('e'), $version));
|
||||
$r = self::runUpdateFunction($version, 'pre_update', $sendMail);
|
||||
if (!$r) {
|
||||
Logger::warning('Pre update failed', ['version' => $version]);
|
||||
DI::logger()->warning('Pre update failed', ['version' => $version]);
|
||||
DI::config()->set('system', 'update', Update::FAILED);
|
||||
DI::lock()->release('dbupdate');
|
||||
DI::config()->beginTransaction()
|
||||
|
@ -216,12 +216,12 @@ class Update
|
|||
->commit();
|
||||
return $r;
|
||||
} else {
|
||||
Logger::notice('Pre update executed.', ['version' => $version]);
|
||||
DI::logger()->notice('Pre update executed.', ['version' => $version]);
|
||||
}
|
||||
}
|
||||
|
||||
// update the structure in one call
|
||||
Logger::notice('Execute structure update');
|
||||
DI::logger()->notice('Execute structure update');
|
||||
$retval = DBStructure::performUpdate(false, $verbose);
|
||||
if (!empty($retval)) {
|
||||
if ($sendMail) {
|
||||
|
@ -230,7 +230,7 @@ class Update
|
|||
$retval
|
||||
);
|
||||
}
|
||||
Logger::error('Update ERROR.', ['from' => $stored, 'to' => $current, 'retval' => $retval]);
|
||||
DI::logger()->error('Update ERROR.', ['from' => $stored, 'to' => $current, 'retval' => $retval]);
|
||||
DI::config()->set('system', 'update', Update::FAILED);
|
||||
DI::lock()->release('dbupdate');
|
||||
DI::config()->beginTransaction()
|
||||
|
@ -239,17 +239,17 @@ class Update
|
|||
->commit();
|
||||
return $retval;
|
||||
} else {
|
||||
Logger::notice('Database structure update finished.', ['from' => $stored, 'to' => $current]);
|
||||
DI::logger()->notice('Database structure update finished.', ['from' => $stored, 'to' => $current]);
|
||||
}
|
||||
|
||||
// run the update_nnnn functions in update.php
|
||||
for ($version = $stored + 1; $version <= $current; $version++) {
|
||||
Logger::notice('Execute post update.', ['version' => $version]);
|
||||
DI::logger()->notice('Execute post update.', ['version' => $version]);
|
||||
DI::config()->set('system', 'maintenance_reason', DI::l10n()->t('%s: executing post update %d',
|
||||
DateTimeFormat::utcNow() . ' ' . date('e'), $version));
|
||||
$r = self::runUpdateFunction($version, 'update', $sendMail);
|
||||
if (!$r) {
|
||||
Logger::warning('Post update failed', ['version' => $version]);
|
||||
DI::logger()->warning('Post update failed', ['version' => $version]);
|
||||
DI::config()->set('system', 'update', Update::FAILED);
|
||||
DI::lock()->release('dbupdate');
|
||||
DI::config()->beginTransaction()
|
||||
|
@ -259,7 +259,7 @@ class Update
|
|||
return $r;
|
||||
} else {
|
||||
DI::config()->set('system', 'build', $version);
|
||||
Logger::notice('Post update executed.', ['version' => $version]);
|
||||
DI::logger()->notice('Post update executed.', ['version' => $version]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -271,12 +271,12 @@ class Update
|
|||
->delete('system', 'maintenance_reason')
|
||||
->commit();
|
||||
|
||||
Logger::notice('Update success.', ['from' => $stored, 'to' => $current]);
|
||||
DI::logger()->notice('Update success.', ['from' => $stored, 'to' => $current]);
|
||||
if ($sendMail) {
|
||||
self::updateSuccessful($stored, $current);
|
||||
}
|
||||
} else {
|
||||
Logger::warning('Update lock could not be acquired');
|
||||
DI::logger()->warning('Update lock could not be acquired');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ class Update
|
|||
{
|
||||
$funcname = $prefix . '_' . $version;
|
||||
|
||||
Logger::notice('Update function start.', ['function' => $funcname]);
|
||||
DI::logger()->notice('Update function start.', ['function' => $funcname]);
|
||||
|
||||
if (function_exists($funcname)) {
|
||||
// There could be a lot of processes running or about to run.
|
||||
|
@ -310,9 +310,9 @@ class Update
|
|||
if (DI::lock()->acquire('dbupdate_function', 120, Cache\Enum\Duration::INFINITE)) {
|
||||
|
||||
// call the specific update
|
||||
Logger::notice('Pre update function start.', ['function' => $funcname]);
|
||||
DI::logger()->notice('Pre update function start.', ['function' => $funcname]);
|
||||
$retval = $funcname();
|
||||
Logger::notice('Update function done.', ['function' => $funcname]);
|
||||
DI::logger()->notice('Update function done.', ['function' => $funcname]);
|
||||
|
||||
if ($retval) {
|
||||
if ($sendMail) {
|
||||
|
@ -322,20 +322,20 @@ class Update
|
|||
DI::l10n()->t('Update %s failed. See error logs.', $version)
|
||||
);
|
||||
}
|
||||
Logger::error('Update function ERROR.', ['function' => $funcname, 'retval' => $retval]);
|
||||
DI::logger()->error('Update function ERROR.', ['function' => $funcname, 'retval' => $retval]);
|
||||
DI::lock()->release('dbupdate_function');
|
||||
return false;
|
||||
} else {
|
||||
DI::lock()->release('dbupdate_function');
|
||||
Logger::notice('Update function finished.', ['function' => $funcname]);
|
||||
DI::logger()->notice('Update function finished.', ['function' => $funcname]);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
Logger::error('Locking failed.', ['function' => $funcname]);
|
||||
DI::logger()->error('Locking failed.', ['function' => $funcname]);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
Logger::notice('Update function skipped.', ['function' => $funcname]);
|
||||
DI::logger()->notice('Update function skipped.', ['function' => $funcname]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ class Update
|
|||
{
|
||||
$adminEmails = User::getAdminListForEmailing(['uid', 'language', 'email']);
|
||||
if (!$adminEmails) {
|
||||
Logger::warning('Cannot notify administrators .', ['update' => $update_id, 'message' => $error_message]);
|
||||
DI::logger()->warning('Cannot notify administrators .', ['update' => $update_id, 'message' => $error_message]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -376,7 +376,7 @@ class Update
|
|||
DI::emailer()->send($email);
|
||||
}
|
||||
|
||||
Logger::alert('Database structure update failed.', ['error' => $error_message]);
|
||||
DI::logger()->alert('Database structure update failed.', ['error' => $error_message]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -404,6 +404,6 @@ class Update
|
|||
DI::emailer()->send($email);
|
||||
}
|
||||
|
||||
Logger::debug('Database structure update successful.');
|
||||
DI::logger()->debug('Database structure update successful.');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue