Skip to content

Commit 83ebd77

Browse files
committed
improved logging
1 parent 68ea397 commit 83ebd77

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

app/Http/Controllers/NetifyLicenceController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ private function run(NetifydLicenceRepository $licenceProvider, NetifydLicenceTy
2020
{
2121
// If license is in cache, return it.
2222
if (Cache::has($licenceType->cacheLabel())) {
23-
Log::debug('Cache hit, serving license.');
23+
Log::debug('Requested netifyd licence found in cache, returning it.');
2424

2525
return response()->json(Cache::get($licenceType->cacheLabel()));
2626
}
2727

28-
Log::debug('Cache miss, listing licenses.');
28+
Log::debug('Requested netifyd licence not found in cache, checking remote server.');
2929
// Check if the community license is on the remote server.
3030
try {
3131
$licences = $licenceProvider->listLicences();
@@ -35,21 +35,21 @@ private function run(NetifydLicenceRepository $licenceProvider, NetifydLicenceTy
3535
$license = array_find($licences, fn ($item) => $item['issued_to'] == $licenceType->label());
3636
// If it doesn't exist, create it.
3737
if ($license == null) {
38-
Log::debug('Requested license not found, creating it.');
38+
Log::debug('Netifyd licence not found on remote server, creating it.');
3939
try {
4040
$license = $licenceProvider->createLicence($licenceType);
4141
} catch (Exception $e) {
4242
return response()->json(['message' => $e->getMessage()], 500);
4343
}
4444
}
4545
// Got license, checking if everything is in place.
46-
Log::debug('License found, checking renewal/expiration.');
46+
Log::debug('Netifyd licence recovered from remote server, checking if it can be renewed.');
4747
$expiration = $license['expire_at']['unix'];
4848
$creation = $license['created_at']['unix'];
4949
$renewalThreshold = ($expiration - $creation) / 2 + $creation;
5050
$now = now()->unix();
5151
if ($renewalThreshold < $now) {
52-
Log::debug('Licence can be renewed, renewing.');
52+
Log::debug('Netifyd licence can be renewed, renewing it.');
5353
try {
5454
$license = $licenceProvider->renewLicence($licenceType, $license['serial']);
5555
} catch (Exception $e) {

0 commit comments

Comments
 (0)