log: add context

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/888/head
Varun Patil 2023-10-22 12:07:22 -07:00
parent 4be31f19d5
commit 1ad0559436
3 changed files with 8 additions and 6 deletions

View File

@ -104,7 +104,7 @@ class IndexJob extends TimedJob
{
if ('success' === $type || 'info' === $type) {
// If this is just an informational message, we log it with level info
$this->logger->info('Memories: '.$msg);
$this->logger->info($msg, ['app' => Application::APPNAME]);
}
if ($this->_hasError && 'success' === $type) {
@ -116,10 +116,10 @@ class IndexJob extends TimedJob
$this->config->setAppValue(Application::APPNAME, 'last_index_job_status_type', $type);
if ('warning' === $type) {
$this->logger->warning('Memories: '.$msg);
$this->logger->warning($msg, ['app' => Application::APPNAME]);
} elseif ('error' === $type) {
$this->_hasError = true;
$this->logger->error('Memories: '.$msg);
$this->logger->error($msg, ['app' => Application::APPNAME]);
}
}
}

View File

@ -72,7 +72,8 @@ class PostWriteListener implements IEventListener
try {
$this->tw->processFile($node);
} catch (\Exception $e) {
$this->logger->error('Memories failed to process file: {message}', [
$this->logger->error('Failed to process file EXIF data', [
'app' => 'memories',
'message' => $e->getMessage(),
]);
}

View File

@ -176,7 +176,8 @@ class Index
} catch (ProcessClosedException $e) {
throw $e;
} catch (\Exception $e) {
$this->logger->error('Failed to index folder {folder}: {error}', [
$this->logger->error('Failed to index folder', [
'app' => 'memories',
'folder' => $folder->getPath(),
'error' => $e->getMessage(),
]);
@ -278,7 +279,7 @@ class Index
*/
private function error(string $message): void
{
$this->logger->error($message);
$this->logger->error($message, ['app' => 'memories']);
if ($this->output) {
$this->output->writeln("<error>{$message}</error>\n");