diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 7961ea753..2716d3197 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -39,7 +39,9 @@ public function __construct(array $urlParams = []) { } public function register(IRegistrationContext $context): void { - $context->registerEventListener(BeforeMessageLoggedEvent::class, LogListener::class); + if (defined('OC_CONSOLE') && \OC_CONSOLE) { + $context->registerEventListener(BeforeMessageLoggedEvent::class, LogListener::class); + } $context->registerService(Formatter::class, function (ContainerInterface $c) { return new Formatter(\OC::$SERVERROOT); }); diff --git a/lib/Listener/LogListener.php b/lib/Listener/LogListener.php index 8d291f752..af63bf4fb 100644 --- a/lib/Listener/LogListener.php +++ b/lib/Listener/LogListener.php @@ -38,14 +38,10 @@ class LogListener implements IEventListener { private ?Console $console; public function __construct(Formatter $formatter, SystemConfig $config) { - if (defined('OC_CONSOLE') && \OC_CONSOLE) { - $level = getenv('OCC_LOG'); - if ($level) { - $terminal = new Terminal(); - $this->console = new Console($formatter, $config, $level, $terminal->getWidth()); - } else { - $this->console = null; - } + $level = getenv('OCC_LOG'); + if ($level) { + $terminal = new Terminal(); + $this->console = new Console($formatter, $config, $level, $terminal->getWidth()); } else { $this->console = null; }