diff --git a/src/app/Jobs/CommonJob.php b/src/app/Jobs/CommonJob.php --- a/src/app/Jobs/CommonJob.php +++ b/src/app/Jobs/CommonJob.php @@ -138,4 +138,12 @@ { return $this->isReleased; } + + /** + * Log human-readable job title (at least contains job class name) + */ + public function logJobStart($ident = null): void + { + \Log::info('Starting ' . $this::class . ($ident ? " for {$ident}" : '')); + } } diff --git a/src/app/Jobs/User/CreateJob.php b/src/app/Jobs/User/CreateJob.php --- a/src/app/Jobs/User/CreateJob.php +++ b/src/app/Jobs/User/CreateJob.php @@ -27,6 +27,8 @@ */ public function handle() { + $this->logJobStart($this->userEmail); + $user = $this->getUser(); if (!$user) { diff --git a/src/app/Jobs/User/DeleteJob.php b/src/app/Jobs/User/DeleteJob.php --- a/src/app/Jobs/User/DeleteJob.php +++ b/src/app/Jobs/User/DeleteJob.php @@ -13,6 +13,8 @@ */ public function handle() { + $this->logJobStart($this->userEmail); + $user = $this->getUser(); if (!$user) { diff --git a/src/app/Jobs/User/ResyncJob.php b/src/app/Jobs/User/ResyncJob.php --- a/src/app/Jobs/User/ResyncJob.php +++ b/src/app/Jobs/User/ResyncJob.php @@ -17,6 +17,8 @@ */ public function handle() { + $this->logJobStart($this->userEmail); + $user = $this->getUser(); if (!$user) { diff --git a/src/app/Jobs/User/UpdateJob.php b/src/app/Jobs/User/UpdateJob.php --- a/src/app/Jobs/User/UpdateJob.php +++ b/src/app/Jobs/User/UpdateJob.php @@ -20,6 +20,8 @@ */ public function handle() { + $this->logJobStart($this->userEmail); + $user = $this->getUser(); if (!$user) { diff --git a/src/app/Jobs/User/VerifyJob.php b/src/app/Jobs/User/VerifyJob.php --- a/src/app/Jobs/User/VerifyJob.php +++ b/src/app/Jobs/User/VerifyJob.php @@ -13,6 +13,8 @@ */ public function handle() { + $this->logJobStart($this->userEmail); + $user = $this->getUser(); if (!$user) { diff --git a/src/app/Jobs/WalletCharge.php b/src/app/Jobs/WalletCharge.php --- a/src/app/Jobs/WalletCharge.php +++ b/src/app/Jobs/WalletCharge.php @@ -4,17 +4,9 @@ use App\Wallet; use App\Http\Controllers\API\V4\PaymentsController; -use Illuminate\Bus\Queueable; -use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Foundation\Bus\Dispatchable; -use Illuminate\Queue\InteractsWithQueue; -class WalletCharge implements ShouldQueue +class WalletCharge extends CommonJob { - use Dispatchable; - use InteractsWithQueue; - use Queueable; - /** @var int How many times retry the job if it fails. */ public $tries = 5; @@ -53,6 +45,8 @@ */ public function handle() { + $this->logJobStart($this->walletId); + if ($wallet = Wallet::find($this->walletId)) { PaymentsController::topUpWallet($wallet); } diff --git a/src/app/Jobs/WalletCheck.php b/src/app/Jobs/WalletCheck.php --- a/src/app/Jobs/WalletCheck.php +++ b/src/app/Jobs/WalletCheck.php @@ -5,17 +5,9 @@ use App\Http\Controllers\API\V4\PaymentsController; use App\Wallet; use Carbon\Carbon; -use Illuminate\Bus\Queueable; -use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Foundation\Bus\Dispatchable; -use Illuminate\Queue\InteractsWithQueue; -class WalletCheck implements ShouldQueue +class WalletCheck extends CommonJob { - use Dispatchable; - use InteractsWithQueue; - use Queueable; - public const THRESHOLD_DEGRADE = 'degrade'; public const THRESHOLD_DEGRADE_REMINDER = 'degrade-reminder'; public const THRESHOLD_BEFORE_DEGRADE = 'before-degrade'; @@ -65,6 +57,8 @@ */ public function handle() { + $this->logJobStart($this->walletId); + $this->wallet = Wallet::find($this->walletId); // Sanity check (owner deleted in meantime)