Skip to content

Commit

Permalink
feat: logging support for requests and responses (#58)
Browse files Browse the repository at this point in the history
This commit adds the configurable logging support via psr/log/LoggerInterface. It adds the ability to log requests and responses for any API call. It also adds the unit tests that cover all aspects of this new feature
  • Loading branch information
asadali214 authored May 9, 2024
1 parent ce29310 commit faea523
Show file tree
Hide file tree
Showing 19 changed files with 1,166 additions and 94 deletions.
3 changes: 2 additions & 1 deletion .phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
$vendor_dir . '/apimatic/core-interfaces',
$vendor_dir . '/apimatic/jsonmapper',
$vendor_dir . '/phpunit/phpunit',
$vendor_dir . '/php-jsonpointer/php-jsonpointer'
$vendor_dir . '/php-jsonpointer/php-jsonpointer',
$vendor_dir . '/psr/log'
],

// A directory list that defines files that will be excluded
Expand Down
54 changes: 33 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ composer require "apimatic/core"
```

## Request
| Name | Description |
|------------------------------------------------------------------------------|-----------------------------------------------------------------------|
| [`AdditionalFormParams`](src/Request/Parameters/AdditionalFormParams.php) | Used to add additional form params to a request |
| [`AdditionalHeaderParams`](src/Request/Parameters/AdditionalHeaderParams.php)| Used to add additional header params to a request |
| [`AdditionalQueryParams`](src/Request/Parameters/AdditionalQueryParams.php) | Used to add additional query params to a request |
| [`BodyParam`](src/Request/Parameters/BodyParam.php) | Body parameter class |
| [`FormParam`](src/Request/Parameters/FormParam.php) | Form parameter class |
| [`HeaderParam`](src/Request/Parameters/HeaderParam.php) | Header parameter class |
| [`QueryParam`](src/Request/Parameters/QueryParam.php) | Query parameter class |
| [`TemplateParam`](src/Request/Parameters/TemplateParam.php) | Template parameter class |
| [`RequestBuilder`](src/Request/RequestBuilder.php) | Used to instantiate a new Request object with the properties provided |
| [`Request`](src/Request/Request.php) | Request class for an API call |
| Name | Description |
|-------------------------------------------------------------------------------|-----------------------------------------------------------------------|
| [`AdditionalFormParams`](src/Request/Parameters/AdditionalFormParams.php) | Used to add additional form params to a request |
| [`AdditionalHeaderParams`](src/Request/Parameters/AdditionalHeaderParams.php) | Used to add additional header params to a request |
| [`AdditionalQueryParams`](src/Request/Parameters/AdditionalQueryParams.php) | Used to add additional query params to a request |
| [`BodyParam`](src/Request/Parameters/BodyParam.php) | Body parameter class |
| [`FormParam`](src/Request/Parameters/FormParam.php) | Form parameter class |
| [`HeaderParam`](src/Request/Parameters/HeaderParam.php) | Header parameter class |
| [`QueryParam`](src/Request/Parameters/QueryParam.php) | Query parameter class |
| [`TemplateParam`](src/Request/Parameters/TemplateParam.php) | Template parameter class |
| [`RequestBuilder`](src/Request/RequestBuilder.php) | Used to instantiate a new Request object with the properties provided |
| [`Request`](src/Request/Request.php) | Request class for an API call |

## Response
| Name | Description |
Expand All @@ -51,16 +51,28 @@ composer require "apimatic/core"
| [`ResponseHandler`](src/Response/ResponseHandler.php) | Response handler for an API call that holds all the above response handling features |
| [`Context`](src/Response/Context.php) | Holds the current context i.e. the current request, response and other needed details |

## Logger
| Name | Description |
|---------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
| [`ApiLogger`](src/Logger/ApiLogger.php) | Provides implementation for logging API requests and responses |
| [`NullApiLogger`](src/Logger/NullApiLogger.php) | Provides the default implementation for ApiLogger when no logging configuration is provided |
| [`ConsoleLogger`](src/Logger/ConsoleLogger.php) | A LoggerInterface implementation that log messages on console |
| [`LoggerConstants`](src/Logger/LoggerConstants.php) | Holds constants like NON_SENSITIVE_HEADERS, etc. |
| [`BaseHttpLoggingConfiguration`](src/Logger/Configuration/BaseHttpLoggingConfiguration.php) | Common configurations shared by request and response logging configurations |
| [`LoggingConfiguration`](src/Logger/Configuration/LoggingConfiguration.php) | Provides client's logging configurations |
| [`RequestConfiguration`](src/Logger/Configuration/RequestConfiguration.php) | Provides request's logging configurations |
| [`ResponseConfiguration`](src/Logger/Configuration/ResponseConfiguration.php) | Provides response's logging configurations |

## TestCase
| Name | Description |
|--------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
| [`KeysAndValuesBodyMatcher`](src/TestCase/BodyMatchers/KeysAndValuesBodyMatcher.php) | Matches actual and expected body, considering both the keys and values |
| [`KeysBodyMatcher`](src/TestCase/BodyMatchers/KeysBodyMatcher.php) | Matches actual and expected body, considering just the keys |
| [`NativeBodyMatcher`](src/TestCase/BodyMatchers/NativeBodyMatcher.php) | A body matcher for native values like string, int etc |
| [`RawBodyMatcher`](src/TestCase/BodyMatchers/RawBodyMatcher.php) | Exactly matches the body received to expected body |
| [`HeadersMatcher`](src/TestCase/HeadersMatcher.php) | Matches the headers received and the headers expected |
| [`StatusCodeMatcher`](src/TestCase/StatusCodeMatcher.php) | Matches the HTTP status codes received to the expected ones |
| [`CoreTestCase`](core-lib-php/src/TestCase/CoreTestCase.php) | Main class for a test case that performs assertions w/ all the above matchers|
| Name | Description |
|--------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|
| [`KeysAndValuesBodyMatcher`](src/TestCase/BodyMatchers/KeysAndValuesBodyMatcher.php) | Matches actual and expected body, considering both the keys and values |
| [`KeysBodyMatcher`](src/TestCase/BodyMatchers/KeysBodyMatcher.php) | Matches actual and expected body, considering just the keys |
| [`NativeBodyMatcher`](src/TestCase/BodyMatchers/NativeBodyMatcher.php) | A body matcher for native values like string, int etc |
| [`RawBodyMatcher`](src/TestCase/BodyMatchers/RawBodyMatcher.php) | Exactly matches the body received to expected body |
| [`HeadersMatcher`](src/TestCase/HeadersMatcher.php) | Matches the headers received and the headers expected |
| [`StatusCodeMatcher`](src/TestCase/StatusCodeMatcher.php) | Matches the HTTP status codes received to the expected ones |
| [`CoreTestCase`](core-lib-php/src/TestCase/CoreTestCase.php) | Main class for a test case that performs assertions w/ all the above matchers |


[packagist-url]: https://packagist.org/packages/apimatic/core
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"ext-curl": "*",
"ext-dom": "*",
"ext-libxml": "*",
"apimatic/core-interfaces": "~0.1.4",
"psr/log": "^1.1.4 || ^2.0.0 || ^3.0.0",
"apimatic/core-interfaces": "~0.1.5",
"apimatic/jsonmapper": "^3.1.1",
"php-jsonpointer/php-jsonpointer": "^3.0.2"
},
Expand Down
138 changes: 69 additions & 69 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit faea523

Please sign in to comment.