Skip to content

Commit

Permalink
Add logging for tracing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
enjinabner committed Nov 23, 2023
1 parent f5fe526 commit 81a0622
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Jobs/ClaimBeam.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Throwable;

class ClaimBeam implements ShouldQueue
Expand Down Expand Up @@ -56,10 +57,17 @@ public function handle(BatchService $batch, WalletService $wallet): void
BeamScan::firstWhere(['wallet_public_key' => $data['wallet_public_key'], 'beam_id' => $data['beam']['id']])?->delete();

DB::commit();

Log::info('Claim beam assigned.', $data);
} else {
Log::info('Claim beam cannot assign.', $data);
$this->release(1);
}
} catch (Throwable $e) {
DB::rollBack();

Log::error('Claim beam error, message:' . $e->getMessage(), $data);

throw $e;
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/Services/BeamService.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\LazyCollection;
use Illuminate\Support\Str;
use Throwable;
Expand Down Expand Up @@ -213,6 +214,7 @@ public function claim(string $code, string $wallet): bool
ClaimBeam::dispatch($claim = $this->buildClaimBeamData($wallet, $beam, $singleUseCode));
event(new BeamClaimPending($claim));
Cache::decrement($key);
Log::info("Claim beam: {$code}, Remaining: " . Cache::get($key), $claim);
} catch (LockTimeoutException $e) {
throw new BeamException(__('enjin-platform-beam::error.unable_to_process'));
} finally {
Expand Down

0 comments on commit 81a0622

Please sign in to comment.