Setup container with explicit LogChannel

This commit is contained in:
Art4 2024-12-26 08:10:06 +00:00
parent cf8ce380b7
commit 0afa5aba63

View file

@ -125,6 +125,8 @@ class App
{ {
$this->setupContainerForAddons(); $this->setupContainerForAddons();
$this->setupContainerForLogger(LogChannel::DEFAULT);
$this->container = $this->container->addRule(Mode::class, [ $this->container = $this->container->addRule(Mode::class, [
'call' => [ 'call' => [
['determineRunMode', [false, $request->getServerParams()], Dice::CHAIN_CALL], ['determineRunMode', [false, $request->getServerParams()], Dice::CHAIN_CALL],
@ -170,9 +172,7 @@ class App
{ {
$this->setupContainerForAddons(); $this->setupContainerForAddons();
$this->container = $this->container->addRule(LoggerInterface::class,[ $this->setupContainerForLogger(LogChannel::AUTH_JABBERED);
'constructParams' => [LogChannel::AUTH_JABBERED],
]);
$this->setupLegacyServerLocator(); $this->setupLegacyServerLocator();
@ -194,9 +194,7 @@ class App
{ {
$this->setupContainerForAddons(); $this->setupContainerForAddons();
$this->container = $this->container->addRule(LoggerInterface::class, [ $this->setupContainerForLogger(LogChannel::CONSOLE);
'constructParams' => [LogChannel::CONSOLE],
]);
$this->setupLegacyServerLocator(); $this->setupLegacyServerLocator();
@ -213,6 +211,13 @@ class App
$this->container = $this->container->addRules($addonLoader->getActiveAddonConfig('dependencies')); $this->container = $this->container->addRules($addonLoader->getActiveAddonConfig('dependencies'));
} }
private function setupContainerForLogger(string $logChannel): void
{
$this->container = $this->container->addRule(LoggerInterface::class, [
'constructParams' => [$logChannel],
]);
}
private function setupLegacyServerLocator(): void private function setupLegacyServerLocator(): void
{ {
\Friendica\DI::init($this->container); \Friendica\DI::init($this->container);