]> git.mxchange.org Git - friendica.git/commitdiff
Adds DI::flushLogger() to renew Logger instances
authorPhilipp <admin@philipp.info>
Sun, 31 Oct 2021 19:15:57 +0000 (20:15 +0100)
committerPhilipp <admin@philipp.info>
Fri, 5 Nov 2021 19:52:31 +0000 (20:52 +0100)
src/Core/Worker.php
src/DI.php
static/dependencies.config.php

index d7133c0b7a1b154ccd6ef3d160c84e7d61afc4fd..faa29717c145b05ae521d25bff671672524ffe63 100644 (file)
@@ -1182,7 +1182,7 @@ class Worker
                // We now are in the new worker
                DBA::connect();
 
-               /// @todo Reinitialize the logger to set a new process_id and uid
+               DI::flushLogger();
                $process = DI::process()->create($pid);
 
                $cycles = 0;
index b758ddab0bb84bd301111f95c26230c935da1edc..692d87870d0f6ce905c76cda049eeec6cbfe5940 100644 (file)
@@ -230,6 +230,18 @@ abstract class DI
        // "LoggerInterface" instances
        //
 
+       /**
+        * Flushes the Logger instance, so the factory is called again
+        * (creates a new id and retrieves the current PID)
+        */
+       public static function flushLogger()
+       {
+               $flushDice = self::$dice
+                       ->addRule(LoggerInterface::class, self::$dice->getRule(LoggerInterface::class))
+                       ->addRule('$devLogger', self::$dice->getRule('$devLogger'));
+               static::init($flushDice);
+       }
+
        /**
         * @return LoggerInterface
         */
index 46463de61e0de1f47056254fcfac53d7d663386e..d3034a2ba59a8bdc91dd402213205357bbcbd95b 100644 (file)
@@ -40,7 +40,6 @@ use Friendica\Core\Config;
 use Friendica\Core\PConfig;
 use Friendica\Core\L10n;
 use Friendica\Core\Lock;
-use Friendica\Core\Process;
 use Friendica\Core\Session\Capability\IHandleSessions;
 use Friendica\Core\Storage\Repository\StorageManager;
 use Friendica\Database\Database;