add logging

This commit is contained in:
Jürgen Mummert
2026-01-09 10:17:57 +01:00
parent 6329c9e790
commit b4cd9199c8
2 changed files with 77 additions and 26 deletions
+25 -3
View File
@@ -24,12 +24,34 @@ class MeilisearchIndexCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->log('Meilisearch index gestartet');
$output->writeln('<info>Meilisearch index started</info>');
$this->indexService->run();
try {
$this->indexService->run();
$output->writeln('<info>Meilisearch index finished</info>');
$this->log('Meilisearch index successfully stopped');
$output->writeln('<info>Meilisearch index finished</info>');
return Command::SUCCESS;
return Command::SUCCESS;
} catch (\Throwable $e) {
$this->log('Meilisearch index ERROR: ' . $e->getMessage());
$output->writeln('<error>' . $e->getMessage() . '</error>');
return Command::FAILURE;
}
}
/**
* Einheitliches Logging mit Zeitstempel
*/
private function log(string $message): void
{
error_log(sprintf(
'[%s] %s',
date('Y-m-d H:i:s'),
$message
));
}
}