From bee8234f19a45d96bcfbe5d1f518e3238658e3e5 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Sat, 4 Mar 2023 01:13:41 +0800 Subject: [PATCH] job add failed log --- app/Jobs/GenerateTemporaryInvite.php | 11 +++++++++++ app/Jobs/SendLoginNotify.php | 11 +++++++++++ app/Jobs/UpdateUserSeedingLeechingTime.php | 11 +++++++++++ 3 files changed, 33 insertions(+) diff --git a/app/Jobs/GenerateTemporaryInvite.php b/app/Jobs/GenerateTemporaryInvite.php index 0def102f..2791cc34 100644 --- a/app/Jobs/GenerateTemporaryInvite.php +++ b/app/Jobs/GenerateTemporaryInvite.php @@ -82,4 +82,15 @@ class GenerateTemporaryInvite implements ShouldQueue } + /** + * Handle a job failure. + * + * @param \Throwable $exception + * @return void + */ + public function failed(\Throwable $exception) + { + do_log("failed: " . $exception->getMessage() . $exception->getTraceAsString(), 'error'); + } + } diff --git a/app/Jobs/SendLoginNotify.php b/app/Jobs/SendLoginNotify.php index b3cbe439..bf5d4eaa 100644 --- a/app/Jobs/SendLoginNotify.php +++ b/app/Jobs/SendLoginNotify.php @@ -57,4 +57,15 @@ class SendLoginNotify implements ShouldQueue $result = $toolRep->sendMail($user->email, $subject, $body); do_log(sprintf('user: %s login notify result: %s', $user->username, var_export($result, true))); } + + /** + * Handle a job failure. + * + * @param \Throwable $exception + * @return void + */ + public function failed(\Throwable $exception) + { + do_log("failed: " . $exception->getMessage() . $exception->getTraceAsString(), 'error'); + } } diff --git a/app/Jobs/UpdateUserSeedingLeechingTime.php b/app/Jobs/UpdateUserSeedingLeechingTime.php index 5e572d71..95dbc307 100644 --- a/app/Jobs/UpdateUserSeedingLeechingTime.php +++ b/app/Jobs/UpdateUserSeedingLeechingTime.php @@ -92,4 +92,15 @@ class UpdateUserSeedingLeechingTime implements ShouldQueue $costTime = time() - $beginTimestamp; do_log("$logPrefix, [DONE], user total count: " . count($users) . ", success update count: $count, cost time: $costTime seconds"); } + + /** + * Handle a job failure. + * + * @param \Throwable $exception + * @return void + */ + public function failed(\Throwable $exception) + { + do_log("failed: " . $exception->getMessage() . $exception->getTraceAsString(), 'error'); + } }