Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply fixes from StyleCI #11

Merged
merged 1 commit into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions config/http-client-logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '',
];
2 changes: 1 addition & 1 deletion src/HttpLoggingFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 0 additions & 1 deletion src/HttpLoggingFilterInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Bilfeldt\LaravelHttpClientLogger;

use Psr\Http\Message\RequestInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/LaravelHttpClientLoggerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class LaravelHttpClientLoggerServiceProvider extends PackageServiceProvider
*
* More info: https://github.com/spatie/laravel-package-tools
*
* @param Package $package
* @param Package $package
*/
public function configurePackage(Package $package): void
{
Expand Down
1 change: 1 addition & 0 deletions src/Middleware/LoggingMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function __construct(HttpLoggerInterface $logger, HttpLoggingFilterInterf
* Called when the middleware is handled by the client.
*
* @param array $context
*
* @return callable
*/
public function __invoke($context = [], $config = []): callable
Expand Down
28 changes: 14 additions & 14 deletions tests/HttpLoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ public function setUp(): void
{
parent::setUp();

$this->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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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']);

Expand All @@ -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'];
});
}
Expand Down