From 240124ad0d88f8017c1b64eee1631b490fc64c46 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Tue, 27 Feb 2024 00:18:41 +0800 Subject: [PATCH] improve GenerateTemporaryInvite log --- app/Jobs/GenerateTemporaryInvite.php | 15 ++++++++++----- include/constants.php | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/Jobs/GenerateTemporaryInvite.php b/app/Jobs/GenerateTemporaryInvite.php index 8dd2fd79..ff1fa2db 100644 --- a/app/Jobs/GenerateTemporaryInvite.php +++ b/app/Jobs/GenerateTemporaryInvite.php @@ -57,14 +57,18 @@ class GenerateTemporaryInvite implements ShouldQueue */ public function handle() { + $beginTimestamp = microtime(true); $toolRep = new ToolRepository(); $idStr = NexusDB::cache_get($this->idRedisKey); + $logPrefix = "idRedisKey: " . $this->idRedisKey; if (empty($idStr)) { - do_log("no idStr of idRedisKey: {$this->idRedisKey}..."); + do_log("$logPrefix, no idStr..."); return; } $idArr = explode(",", $idStr); - do_log(sprintf("going to handle %d uid...", count($idArr))); + $count = count($idArr); + $logPrefix .= ", count: $count"; + do_log("$logPrefix, going to handle..."); $now = Carbon::now(); $expiredAt = Carbon::now()->addDays($this->days); foreach ($idArr as $uid) { @@ -84,12 +88,13 @@ class GenerateTemporaryInvite implements ShouldQueue if (!empty($data)) { Invite::query()->insert($data); } - do_log("success add $this->count temporary invite ($this->days days) to $uid"); + do_log("$logPrefix, success add $this->count temporary invite ($this->days days) to $uid"); } catch (\Exception $exception) { - do_log("fail add $this->count temporary invite ($this->days days) to $uid: " . $exception->getMessage(), 'error'); + do_log("$logPrefix, fail add $this->count temporary invite ($this->days days) to $uid: " . $exception->getMessage(), 'error'); } } - + NexusDB::cache_del($this->idRedisKey); + do_log("$logPrefix, handle done, cost time: " . (microtime(true) - $beginTimestamp) . " seconds."); } /** diff --git a/include/constants.php b/include/constants.php index a783f8de..ba074904 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@