Adds DI::flushLogger() to renew Logger instances

This commit is contained in:
Philipp 2021-10-31 20:15:57 +01:00
parent 7637ae1dcc
commit 32f0c3fb9c
No known key found for this signature in database
GPG Key ID: 24A7501396EB5432
3 changed files with 13 additions and 2 deletions

View File

@ -1182,7 +1182,7 @@ class Worker
// We now are in the new worker // We now are in the new worker
DBA::connect(); DBA::connect();
/// @todo Reinitialize the logger to set a new process_id and uid DI::flushLogger();
$process = DI::process()->create($pid); $process = DI::process()->create($pid);
$cycles = 0; $cycles = 0;

View File

@ -230,6 +230,18 @@ abstract class DI
// "LoggerInterface" instances // "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 * @return LoggerInterface
*/ */

View File

@ -40,7 +40,6 @@ use Friendica\Core\Config;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Lock; use Friendica\Core\Lock;
use Friendica\Core\Process;
use Friendica\Core\Session\Capability\IHandleSessions; use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\Core\Storage\Repository\StorageManager; use Friendica\Core\Storage\Repository\StorageManager;
use Friendica\Database\Database; use Friendica\Database\Database;