diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 595ad14cd..403a7fdfd 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -24,7 +24,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 ee86c834f..ca9d650b3 100644 --- a/lib/Listener/LogListener.php +++ b/lib/Listener/LogListener.php @@ -23,14 +23,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; }