]> git.mxchange.org Git - friendica.git/commitdiff
Refactor dynamic App::getLogger() to static DI::logger()
authornupplaPhil <admin@philipp.info>
Sun, 15 Dec 2019 22:46:56 +0000 (23:46 +0100)
committernupplaPhil <admin@philipp.info>
Sun, 29 Dec 2019 19:17:41 +0000 (20:17 +0100)
include/api.php
src/App.php
src/App/Authentication.php
src/Core/Worker.php
src/Model/Nodeinfo.php
src/Module/Admin/Summary.php
src/Module/Filer/RemoveTag.php
src/Module/Filer/SaveTag.php
src/Module/Statistics.php

index 363a0b970086517ef425ac2c60d9a9b884897e09..12f5dcb8ab841b5e327d0e77e6e55d7779a98330 100644 (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) {
                                        /*
index 6f1045ada5e67dd7f452024b251699962367187b..ac0f45f9b583307269b85f813ae5a94f1d0f28b5 100644 (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
         *
index b88690415ca9ce7e4a9e1f88aa3577c46e3e0b36..b1424e0fd63ea9e3ea9377c0790341712ad0c9d3 100644 (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');
                        }
index a87fef07713b7055f4ccfb6e825e4d241254d6ad..d4a90dd1969edc86011965847170da34c6e29b9a 100644 (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.
index 58a9e45447a0d4a79be8c9167576cbbb36e85da9..6d9c77154a17b720c570f3ab04663c05e39b7b94 100644 (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')) {
index 60b35289c9427ba559fd572711e98bcc7ef541af..d634b89fbf6a65d52a82cd83afbc759e8807571d 100644 (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,
                                ]);
index 65fd6cdf362288d6bff78117e7af9c4c06a56788..5ecaf4c2f9cdda530aa5fe711811bf44f3222427 100644 (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);
 
index 1e19cdff19df8483b47b681cde3273abef69611a..9c0709db908ca4e62da3f90dcbcd1924162cdedc 100644 (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
index 11cbdf53afb0f33ec8279cf09ae51c3fc0d32bd1..ce15426b8aea1d680e1eb4627f90fda38b66a13c 100644 (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