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

Added support for PSR-3 #272

Merged
merged 2 commits into from
Mar 1, 2021
Merged

Conversation

dragonmantank
Copy link
Contributor

Description

This adds support for PSR-3, which enables standardized logging. It also allows enabling a "debug" flag that will log out a Request and associated Response if a logger is set at DEBUG level.

This does not provide a logger itself, just allows a PSR-3 compatible logger to be passed in via the MapFactory and setting something to the PSR\Log\LoggerInterface key. The user is responsible for providing the logger that the client will use.

This also allows us to add logging capabilities to the individual APIs as well later down the line.

Motivation and Context

Logging is a standard thing most applications do. Users can now get basic logging from our system. Request/Response logging is available as it is the most common debugging information that is needed.

How Has This Been Tested?

Test scripts using Monolog as a logging solution.

Example Output or Screenshots (if appropriate):

To enable logging, you will need to enable the new debug flag as well as pass a PSR-3 compliant logger such as Monolog (not shipped with our library):

$client = new Vonage\Client(new Basic('abcd1234', 's3cr3tk3y'), ['debug' => true]);
$logger = new Monolog\Logger('test');
$logger->pushHandler(new StreamHandler(__DIR__ . '/log.txt'));
$client->getFactory()->set(LoggerInterface::class, $logger);

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@dragonmantank dragonmantank force-pushed the enhancement/devx-5063-add-logging branch from c710209 to f283426 Compare February 22, 2021 20:55
@codecov-io
Copy link

codecov-io commented Feb 22, 2021

Codecov Report

Merging #272 (f283426) into master (c9bd018) will decrease coverage by 0.11%.
The diff coverage is 48.57%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #272      +/-   ##
============================================
- Coverage     80.56%   80.45%   -0.12%     
- Complexity     2446     2460      +14     
============================================
  Files           166      167       +1     
  Lines          6042     6077      +35     
============================================
+ Hits           4868     4889      +21     
- Misses         1174     1188      +14     
Impacted Files Coverage Δ Complexity Δ
src/Client.php 76.67% <26.08%> (-4.19%) 82.00 <4.00> (+6.00) ⬇️
src/Client/Factory/MapFactory.php 86.48% <75.00%> (+4.66%) 16.00 <0.00> (+3.00)
src/Logger/LoggerTrait.php 100.00% <100.00%> (ø) 5.00 <5.00> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c9bd018...f283426. Read the comment docs.

@dragonmantank dragonmantank changed the base branch from master to 2.x February 23, 2021 03:38
Copy link
Contributor

@GregHolmes GregHolmes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added one suggestion for the README, as you hadn't included the full namespace for the Basic class.

README.md Outdated Show resolved Hide resolved
Co-authored-by: Greg Holmes <greg.holmes2@vonage.com>
@dragonmantank dragonmantank merged commit 799e66d into 2.x Mar 1, 2021
dragonmantank added a commit to Nexmo/nexmo-php that referenced this pull request Mar 1, 2021
* Added support for PSR-3

Co-authored-by: Greg Holmes <greg.holmes2@vonage.com>
@SecondeJK SecondeJK deleted the enhancement/devx-5063-add-logging branch January 18, 2022 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants