add logging
This commit is contained in:
@@ -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
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user