From 1ad05594369f0926964512b0b0714be7d4c3c8b6 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Sun, 22 Oct 2023 12:07:22 -0700 Subject: [PATCH] log: add context Signed-off-by: Varun Patil --- lib/Cron/IndexJob.php | 6 +++--- lib/Listeners/PostWriteListener.php | 3 ++- lib/Service/Index.php | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/Cron/IndexJob.php b/lib/Cron/IndexJob.php index c755261c..c0658e8a 100644 --- a/lib/Cron/IndexJob.php +++ b/lib/Cron/IndexJob.php @@ -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]); } } } diff --git a/lib/Listeners/PostWriteListener.php b/lib/Listeners/PostWriteListener.php index acaaad46..eb630205 100644 --- a/lib/Listeners/PostWriteListener.php +++ b/lib/Listeners/PostWriteListener.php @@ -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(), ]); } diff --git a/lib/Service/Index.php b/lib/Service/Index.php index e278c213..a5d3a60b 100644 --- a/lib/Service/Index.php +++ b/lib/Service/Index.php @@ -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("{$message}\n");