Skip to content

Commit a804c96

Browse files
fix(log): Fix empty logs
1 parent 6879056 commit a804c96

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

tests/GeolocationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public function testCanVerifyIpAndCountryWithMaxmindInStreamMode(array $maxmindC
163163
// Warm BlockList cache up
164164
$bouncer->refreshBlocklistCache();
165165

166-
$this->logger->debug('Refresh the cache just after the warm up. Nothing should append.');
166+
$this->logger->debug('', ['message' =>'Refresh the cache just after the warm up. Nothing should append.']);
167167
$bouncer->refreshBlocklistCache();
168168

169169
$this->assertEquals(

tests/IpVerificationTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ public function testCanVerifyIpInLiveModeWithCacheSystem(AbstractAdapter $cacheA
111111
unset($bouncerConfig['max_remediation_level']);
112112
$bouncer->configure($bouncerConfig);
113113

114-
$this->logger->info('set "Large IPV4 range banned" state');
114+
$this->logger->info('', ['message' => 'set "Large IPV4 range banned" state']);
115115
$this->watcherClient->deleteAllDecisions();
116116
$this->watcherClient->addDecision(new \DateTime(), '24h', '+24 hours', TestHelpers::BAD_IP.'/'.TestHelpers::LARGE_IPV4_RANGE, 'ban');
117117
$cappedRemediation = $bouncer->getRemediationForIp(TestHelpers::BAD_IP);
118118
$this->assertEquals('ban', $cappedRemediation, 'The remediation for the banned IP with a too large range should now be "ban" as we are in live mode');
119119

120-
$this->logger->info('set "IPV6 range banned" state');
120+
$this->logger->info('',['message' => 'set "IPV6 range banned" state']);
121121
$this->watcherClient->deleteAllDecisions();
122122
$this->watcherClient->addDecision(new \DateTime(), '24h', '+24 hours', TestHelpers::BAD_IPV6.'/'.TestHelpers::IPV6_RANGE, 'ban');
123123
$cappedRemediation = $bouncer->getRemediationForIp(TestHelpers::BAD_IPV6);
@@ -163,7 +163,7 @@ public function testCanVerifyIpInStreamModeWithCacheSystem(AbstractAdapter $cach
163163

164164
$bouncer->refreshBlocklistCache();
165165

166-
$this->logger->debug('Refresh the cache just after the warm up. Nothing should append.');
166+
$this->logger->debug('', ['message' => 'Refresh the cache just after the warm up. Nothing should append.']);
167167
$bouncer->refreshBlocklistCache();
168168

169169
$this->assertEquals(
@@ -199,10 +199,10 @@ public function testCanVerifyIpInStreamModeWithCacheSystem(AbstractAdapter $cach
199199
// Pull updates
200200
$bouncer->refreshBlocklistCache();
201201

202-
$this->logger->debug('Refresh 2nd time the cache. Nothing should append.');
202+
$this->logger->debug('', ['message' => 'Refresh 2nd time the cache. Nothing should append.']);
203203
$bouncer->refreshBlocklistCache();
204204

205-
$this->logger->debug('Refresh 3rd time the cache. Nothing should append.');
205+
$this->logger->debug('', ['message' => 'Refresh 3rd time the cache. Nothing should append.']);
206206
$bouncer->refreshBlocklistCache();
207207

208208
$this->assertEquals(
@@ -245,7 +245,7 @@ public function testCanVerifyIpInStreamModeWithCacheSystem(AbstractAdapter $cach
245245
'The cache warm up should be stored across each instanciation'
246246
);
247247

248-
$this->logger->info('set "Large IPV4 range banned" + "IPV6 range banned" state');
248+
$this->logger->info('', ['message' => 'set "Large IPV4 range banned" + "IPV6 range banned" state']);
249249
$this->watcherClient->deleteAllDecisions();
250250
$this->watcherClient->addDecision(new \DateTime(), '24h', '+24 hours', TestHelpers::BAD_IP.'/'.TestHelpers::LARGE_IPV4_RANGE, 'ban');
251251
$this->watcherClient->addDecision(new \DateTime(), '24h', '+24 hours', TestHelpers::BAD_IPV6.'/'.TestHelpers::IPV6_RANGE, 'ban');

tests/WatcherClient.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ public function configure(): void
4545
];
4646
$this->watcherClient = new RestClient($this->logger);
4747
$this->watcherClient->configure($apiUrl, $this->baseHeaders, 2);
48-
$this->logger->info('Watcher client initialized');
48+
$this->logger->info('', ['message' => 'Watcher client initialized']);
4949
}
5050

5151
/** Set the initial watcher state */
5252
public function setInitialState(): void
5353
{
54-
$this->logger->info('Set initial state');
54+
$this->logger->info('', ['message' => 'Set initial state']);
5555
$this->deleteAllDecisions();
5656
$now = new DateTime();
5757
$this->addDecision($now, '12h', '+12 hours', TestHelpers::BAD_IP, 'captcha');
@@ -62,7 +62,7 @@ public function setInitialState(): void
6262
/** Set the second watcher state */
6363
public function setSecondState(): void
6464
{
65-
$this->logger->info('Set "second" state');
65+
$this->logger->info('', ['message' => 'Set "second" state']);
6666
$this->deleteAllDecisions();
6767
$now = new DateTime();
6868
$this->addDecision($now, '36h', '+36 hours', TestHelpers::NEWLY_BAD_IP, 'ban');
@@ -102,7 +102,7 @@ private function request(string $endpoint, array $queryParams = null, array $bod
102102
public function deleteAllDecisions(): void
103103
{
104104
// Delete all existing decisions.
105-
$this->logger->info('Delete all decisions');
105+
$this->logger->info('', ['message' => 'Delete all decisions']);
106106
$this->request('/v1/decisions', null, null, 'DELETE');
107107
}
108108

@@ -146,6 +146,6 @@ public function addDecision(DateTime $now, string $durationString, string $dateT
146146
'stop_at' => $stopAt,
147147
];
148148
$result = $this->request('/v1/alerts', null, [$body], 'POST');
149-
$this->logger->info('Decision '.$result[0].' added: '.$body['decisions'][0]['scenario'].'');
149+
$this->logger->info('', ['message' => 'Decision '.$result[0].' added: '.$body['decisions'][0]['scenario'].'']);
150150
}
151151
}

0 commit comments

Comments
 (0)