1
1
Fork 0

Refactor dynamic App::getLogger() to static DI::logger()

This commit is contained in:
Philipp Holzer 2019-12-15 23:46:56 +01:00
parent fceb4f3823
commit e2b2778e0a
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
9 changed files with 11 additions and 22 deletions

View file

@ -328,7 +328,7 @@ function api_call(App $a)
Logger::info(API_LOG_PREFIX . 'username {username}', ['module' => 'api', 'action' => 'call', 'username' => $a->user['username'], 'duration' => round($duration, 2)]);
$a->getProfiler()->saveLog($a->getLogger(), API_LOG_PREFIX . 'performance');
$a->getProfiler()->saveLog(DI::logger(), API_LOG_PREFIX . 'performance');
if (false === $return) {
/*

View file

@ -155,16 +155,6 @@ class App
return $this->config->getCache()->get('system', 'basepath');
}
/**
* The Logger of this app
*
* @return LoggerInterface
*/
public function getLogger()
{
return $this->logger;
}
/**
* The profiler of this app
*

View file

@ -351,7 +351,7 @@ class Authentication
* The week ensures that sessions will expire after some inactivity.
*/;
if ($this->session->get('remember')) {
$a->getLogger()->info('Injecting cookie for remembered user ' . $user_record['nickname']);
$this->logger->info('Injecting cookie for remembered user ' . $user_record['nickname']);
$this->cookie->set($user_record['uid'], $user_record['password'], $user_record['prvkey']);
$this->session->remove('remember');
}

View file

@ -443,7 +443,7 @@ class Worker
Logger::info('Process done.', ['priority' => $queue["priority"], 'id' => $queue["id"], 'duration' => round($duration, 3)]);
$a->getProfiler()->saveLog($a->getLogger(), "ID " . $queue["id"] . ": " . $funcname);
$a->getProfiler()->saveLog(DI::logger(), "ID " . $queue["id"] . ": " . $funcname);
$cooldown = Config::get("system", "worker_cooldown", 0);
@ -1086,7 +1086,7 @@ class Worker
$args = ['no_cron' => !$do_cron];
$a = get_app();
$process = new Core\Process($a->getLogger(), $a->getMode(), DI::config(), $a->getBasePath());
$process = new Core\Process(DI::logger(), $a->getMode(), DI::config(), $a->getBasePath());
$process->run($command, $args);
// after spawning we have to remove the flag.

View file

@ -18,9 +18,8 @@ class Nodeinfo
*/
public static function update()
{
$app = DI::app();
$config = DI::config();
$logger = $app->getLogger();
$logger = DI::logger();
// If the addon 'statistics_json' is enabled then disable it and activate nodeinfo.
if (Addon::isEnabled('statistics_json')) {

View file

@ -118,7 +118,7 @@ class Summary extends BaseAdminModule
$currBasepath = DI::config()->get('system', 'basepath');
if ($confBasepath !== $currBasepath || !is_dir($currBasepath)) {
if (is_dir($confBasepath) && Config::set('system', 'basepath', $confBasepath)) {
$a->getLogger()->info('Friendica\'s system.basepath was updated successfully.', [
DI::logger()->info('Friendica\'s system.basepath was updated successfully.', [
'from' => $currBasepath,
'to' => $confBasepath,
]);
@ -126,7 +126,7 @@ class Summary extends BaseAdminModule
$currBasepath,
$confBasepath);
} elseif (!is_dir($currBasepath)) {
$a->getLogger()->alert('Friendica\'s system.basepath is wrong.', [
DI::logger()->alert('Friendica\'s system.basepath is wrong.', [
'from' => $currBasepath,
'to' => $confBasepath,
]);
@ -134,7 +134,7 @@ class Summary extends BaseAdminModule
$currBasepath,
$confBasepath);
} else {
$a->getLogger()->alert('Friendica\'s system.basepath is wrong.', [
DI::logger()->alert('Friendica\'s system.basepath is wrong.', [
'from' => $currBasepath,
'to' => $confBasepath,
]);

View file

@ -20,7 +20,7 @@ class RemoveTag extends BaseModule
}
$app = DI::app();
$logger = $app->getLogger();
$logger = DI::logger();
$item_id = (($app->argc > 1) ? intval($app->argv[1]) : 0);

View file

@ -26,7 +26,7 @@ class SaveTag extends BaseModule
public static function rawContent(array $parameters = [])
{
$a = DI::app();
$logger = $a->getLogger();
$logger = DI::logger();
$term = XML::unescape(trim($_GET['term'] ?? ''));
// @TODO: Replace with parameter from router

View file

@ -19,7 +19,7 @@ class Statistics extends BaseModule
public static function rawContent(array $parameters = [])
{
$config = DI::config();
$logger = DI::app()->getLogger();
$logger = DI::logger();
$registration_open =
intval($config->get('config', 'register_policy')) !== Register::CLOSED