Skip to content

Commit b4a7c02

Browse files
authored
Merge pull request #1577 from nextcloud/artonge/optim/dont_register_listener_if_not_console
fix: Do not register listener when not in console
2 parents 8c888f9 + 16bd650 commit b4a7c02

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

lib/AppInfo/Application.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ public function __construct(array $urlParams = []) {
2424
}
2525

2626
public function register(IRegistrationContext $context): void {
27-
$context->registerEventListener(BeforeMessageLoggedEvent::class, LogListener::class);
27+
if (defined('OC_CONSOLE') && \OC_CONSOLE) {
28+
$context->registerEventListener(BeforeMessageLoggedEvent::class, LogListener::class);
29+
}
2830
$context->registerService(Formatter::class, function (ContainerInterface $c) {
2931
return new Formatter(\OC::$SERVERROOT);
3032
});

lib/Listener/LogListener.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,10 @@ class LogListener implements IEventListener {
2323
private ?Console $console;
2424

2525
public function __construct(Formatter $formatter, SystemConfig $config) {
26-
if (defined('OC_CONSOLE') && \OC_CONSOLE) {
27-
$level = getenv('OCC_LOG');
28-
if ($level) {
29-
$terminal = new Terminal();
30-
$this->console = new Console($formatter, $config, $level, $terminal->getWidth());
31-
} else {
32-
$this->console = null;
33-
}
26+
$level = getenv('OCC_LOG');
27+
if ($level) {
28+
$terminal = new Terminal();
29+
$this->console = new Console($formatter, $config, $level, $terminal->getWidth());
3430
} else {
3531
$this->console = null;
3632
}

0 commit comments

Comments
 (0)