$this->setupContainerForAddons();
- $this->container->setup(LogChannel::APP);
+ $this->setupContainerForLogger(LogChannel::APP);
+
+ $this->container->setup();
$this->registerErrorHandler();
{
$this->setupContainerForAddons();
+ $this->setupContainerForLogger($this->determineLogChannel($argv));
+
+ $this->container->setup();
+
$this->registerErrorHandler();
$this->registerTemplateEngine();
{
$this->setupContainerForAddons();
- $this->container->setup(LogChannel::AUTH_JABBERED);
+ $this->setupContainerForLogger(LogChannel::AUTH_JABBERED);
+
+ $this->container->setup();
$this->registerErrorHandler();
}
}
+ private function determineLogChannel(array $argv): string
+ {
+ $command = strtolower($argv[1]) ?? '';
+
+ if ($command === 'daemon' || $command === 'jetstream') {
+ return LogChannel::DAEMON;
+ }
+
+ if ($command === 'worker') {
+ return LogChannel::WORKER;
+ }
+
+ // @TODO Add support for jetstream
+
+ return LogChannel::CONSOLE;
+ }
+
+ private function setupContainerForLogger(string $logChannel): void
+ {
+ $this->container->addRule(LoggerInterface::class, [
+ 'constructParams' => [$logChannel],
+ ]);
+ }
+
private function registerErrorHandler(): void
{
ErrorHandler::register($this->container->create(LoggerInterface::class));
$className = $this->subConsoles[$command];
- if (is_subclass_of($className, Friendica\Console\AbstractConsole::class)) {
- $this->container->setup($className::LOG_CHANNEL);
- } else {
- $this->container->setup(LogChannel::CONSOLE);
- }
-
/** @var Console $subconsole */
$subconsole = $this->container->create($className, [$subargs]);
use Dice\Dice;
use Friendica\DI;
-use Psr\Log\LoggerInterface;
/**
* Wrapper for the Dice class to make some basic setups
*
* @deprecated
*
- * @param string $logChannel The Log Channel of this call
- *
* @return void
*/
- public function setup(string $logChannel): void
+ public function setup(): void
{
- $this->setupContainerForLogger($logChannel);
$this->setupLegacyServiceLocator();
}
$this->container = $this->container->addRule($name, $rule);
}
- private function setupContainerForLogger(string $logChannel): void
- {
- $this->container = $this->container->addRule(LoggerInterface::class, [
- 'constructParams' => [$logChannel],
- ]);
- }
-
private function setupLegacyServiceLocator(): void
{
DI::init($this->container);