index: add verbose logging

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/929/head
Varun Patil 2023-11-17 10:20:49 -08:00
parent 208939464b
commit f38f5e15da
2 changed files with 8 additions and 7 deletions

View File

@ -99,6 +99,7 @@ class Index extends Command
// Assign to indexer // Assign to indexer
$this->indexer->output = $output; $this->indexer->output = $output;
$this->indexer->section = $output->section(); $this->indexer->section = $output->section();
$this->indexer->verbose = $output->isVerbose();
try { try {
// Use static exiftool process // Use static exiftool process

View File

@ -43,6 +43,7 @@ class Index
{ {
public ?OutputInterface $output = null; public ?OutputInterface $output = null;
public ?ConsoleSectionOutput $section = null; public ?ConsoleSectionOutput $section = null;
public bool $verbose = false;
/** /**
* Callback to check if the process should continue. * Callback to check if the process should continue.
@ -114,8 +115,11 @@ class Index
*/ */
public function indexFolder(Folder $folder): void public function indexFolder(Folder $folder): void
{ {
$path = $folder->getPath();
$this->log("Indexing folder {$path}", true);
if ($folder->nodeExists('.nomedia') || $folder->nodeExists('.nomemories')) { if ($folder->nodeExists('.nomedia') || $folder->nodeExists('.nomemories')) {
$this->log("Skipping folder {$folder->getPath()} (.nomedia / .nomemories)\n", true); $this->log("Skipping folder {$path} (.nomedia / .nomemories)\n", true);
return; return;
} }
@ -177,11 +181,7 @@ class Index
} catch (ProcessClosedException $e) { } catch (ProcessClosedException $e) {
throw $e; throw $e;
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->error('Failed to index folder', [ $this->error("Failed to index folder {$folder->getPath()}: {$e->getMessage()}");
'app' => 'memories',
'folder' => $folder->getPath(),
'error' => $e->getMessage(),
]);
} }
} }
} }
@ -293,7 +293,7 @@ class Index
private function log(string $message, bool $overwrite = false): void private function log(string $message, bool $overwrite = false): void
{ {
if ($this->section) { if ($this->section) {
if ($overwrite) { if ($overwrite && !$this->verbose) {
$this->section->clear(1); $this->section->clear(1);
} }
$this->section->write($message); $this->section->write($message);