diff --git a/config/http-client-logger.php b/config/http-client-logger.php index 5e76147..8ad1436 100644 --- a/config/http-client-logger.php +++ b/config/http-client-logger.php @@ -79,8 +79,8 @@ | Note that these settings are only used by the default logger. | */ - 'disk' => env('HTTP_CLIENT_LOGGER_DISK', false), + 'disk' => env('HTTP_CLIENT_LOGGER_DISK', false), 'disk_separate_files' => true, - 'prefix_timestamp' => 'Y-m-d-Hisu', // Leaving empty will remove the timestamp - 'filename' => '', + 'prefix_timestamp' => 'Y-m-d-Hisu', // Leaving empty will remove the timestamp + 'filename' => '', ]; diff --git a/src/HttpLoggingFilter.php b/src/HttpLoggingFilter.php index a76a217..12251de 100644 --- a/src/HttpLoggingFilter.php +++ b/src/HttpLoggingFilter.php @@ -14,7 +14,7 @@ public function shouldLog( array $context = [], array $config = [] ): bool { - if (! config('http-client-logger.enabled')) { + if (!config('http-client-logger.enabled')) { return false; } diff --git a/src/HttpLoggingFilterInterface.php b/src/HttpLoggingFilterInterface.php index 1b0ff7e..ebb34e2 100644 --- a/src/HttpLoggingFilterInterface.php +++ b/src/HttpLoggingFilterInterface.php @@ -1,6 +1,5 @@ logger = new HttpLogger(new PsrMessageToStringConverter); + $this->logger = new HttpLogger(new PsrMessageToStringConverter()); $this->request = new Request('GET', 'https://example.com/path?query=ABCDEF', ['header1' => 'HIJKL'], 'TestRequestBody'); } public function test_response_code_200_logs_debug_level() { - Log::swap(new LogFake); + Log::swap(new LogFake()); $this->logger->log($this->request, new Response(200), 0.2); @@ -35,7 +35,7 @@ public function test_response_code_200_logs_debug_level() public function test_response_code_300_logs_info_level() { - Log::swap(new LogFake); + Log::swap(new LogFake()); $this->logger->log($this->request, new Response(300), 0.2); @@ -44,7 +44,7 @@ public function test_response_code_300_logs_info_level() public function test_response_code_400_logs_error_level() { - Log::swap(new LogFake); + Log::swap(new LogFake()); $this->logger->log($this->request, new Response(400), 0.2); @@ -53,7 +53,7 @@ public function test_response_code_400_logs_error_level() public function test_response_code_400_logs_critical_level() { - Log::swap(new LogFake); + Log::swap(new LogFake()); $this->logger->log($this->request, new Response(500), 0.2); @@ -62,7 +62,7 @@ public function test_response_code_400_logs_critical_level() public function test_log_contains_request_header() { - Log::swap(new LogFake); + Log::swap(new LogFake()); $this->logger->log($this->request, new Response(200), 0.2); @@ -73,7 +73,7 @@ public function test_log_contains_request_header() public function test_log_contains_request_body() { - Log::swap(new LogFake); + Log::swap(new LogFake()); $this->logger->log($this->request, new Response(200), 0.2); @@ -84,7 +84,7 @@ public function test_log_contains_request_body() public function test_log_contains_response_header() { - Log::swap(new LogFake); + Log::swap(new LogFake()); $this->logger->log($this->request, new Response(200, ['header2' => 'XYZ']), 0.2); @@ -95,7 +95,7 @@ public function test_log_contains_response_header() public function test_log_contains_response_body() { - Log::swap(new LogFake); + Log::swap(new LogFake()); $this->logger->log($this->request, new Response(200, [], 'TestResponseBody'), 0.2); @@ -106,7 +106,7 @@ public function test_log_contains_response_body() public function test_logs_context() { - Log::swap(new LogFake); + Log::swap(new LogFake()); $this->logger->log($this->request, new Response(200), 0.2, ['context']); @@ -117,26 +117,26 @@ public function test_logs_context() public function test_replaces_placeholders_from_request() { - Log::swap(new LogFake); + Log::swap(new LogFake()); $this->logger->log($this->request, new Response(200), 0.2, ['test123'], ['replace' => ['example.com' => 'mock.org']]); Log::assertLogged('debug', function ($message, $context) { return Str::contains($message, 'mock.org') - && ! Str::contains($message, 'example.com') + && !Str::contains($message, 'example.com') && $context == ['test123']; }); } public function test_replaces_placeholders_from_response() { - Log::swap(new LogFake); + Log::swap(new LogFake()); $this->logger->log($this->request, new Response(200, [], 'My name is John Doe'), 0.2, ['test123'], ['replace' => ['Doe' => 'Smith']]); Log::assertLogged('debug', function ($message, $context) { return Str::contains($message, 'Smith') - && ! Str::contains($message, 'Doe') + && !Str::contains($message, 'Doe') && $context == ['test123']; }); }