-
Notifications
You must be signed in to change notification settings - Fork 69
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
Enhance plugin logging to provide more context information and request IDs #9853
Open
dmvrtx
wants to merge
35
commits into
develop
Choose a base branch
from
dev/hack-logging-enhancements
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
1854c5e
Initial attempt to add request IDs and context to the messages
dmvrtx e02b9fd
Split responsibilities by adding a Logger Context management class
dmvrtx 6a97436
Merge branch 'develop' into dev/hack-logging-enhancements
dmvrtx 62a094d
Update type hints
dmvrtx c739949
Example usage and simplification of checks
dmvrtx f48b470
Log context only if it is updated, improve log line readability, add …
dmvrtx 82602b9
Minor improvements and one more suggested application
dmvrtx 819ef17
Fix unit tests after moving environment data into context
dmvrtx b70f125
Merge branch 'develop' into dev/hack-logging-enhancements
dmvrtx 708e13f
Initial test suite for logger context
dmvrtx 0f697a6
Merge branch 'develop' into dev/hack-logging-enhancements
dmvrtx 7f5955d
Test both options of working with Logger Context
dmvrtx fdbcfd7
Update tests to ensure full code paths coverage
dmvrtx e4b1b11
Better handling JSON encoding errors
dmvrtx 6dd09ed
Fix incorrect class usage
dmvrtx 7e20321
Changelog entry
dmvrtx 3927d38
Merge branch 'develop' into dev/hack-logging-enhancements
dmvrtx d16d5c5
Group logging of the request arguments
dmvrtx c47ea0c
Ensure data is redacted before being logged and update tests
dmvrtx 9b5374f
Merge branch 'develop' into dev/hack-logging-enhancements
dmvrtx 13933bb
Add indicator that object data is JSON-encoded and remove redundant m…
dmvrtx c2a0813
Merge branch 'develop' into dev/hack-logging-enhancements
dmvrtx 269930d
Merge branch 'develop' into dev/hack-logging-enhancements
dmvrtx 2101afd
Merge branch 'develop' into dev/hack-logging-enhancements
dmvrtx 423deca
Merge branch 'develop' into dev/hack-logging-enhancements
dmvrtx 794b26d
Merge branch 'develop' into dev/hack-logging-enhancements
dmvrtx aeefacb
Clean-up and minor improvements in log structure
dmvrtx 2848fa1
Minor clean-ups
dmvrtx 4574d66
Merge branch 'develop' into dev/hack-logging-enhancements
dmvrtx f15ef1f
Merge branch 'develop' into dev/hack-logging-enhancements
dmvrtx 23ca72e
Move logger context initialization to a proper place
dmvrtx 2053c1b
Split initialization steps for clarity
dmvrtx ed0b58c
Properly update tests
dmvrtx 16cace3
Merge branch 'develop' into dev/hack-logging-enhancements
dmvrtx d700fbb
Merge branch 'develop' into dev/hack-logging-enhancements
dmvrtx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: dev | ||
|
||
Enhance log file format to provide more information about the request flow. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/** | ||
* Class LoggerContext | ||
* | ||
* @package WooCommerce\Payments | ||
*/ | ||
|
||
namespace WCPay; | ||
|
||
use WCPay\Internal\LoggerContext as InternalLoggerContext; | ||
|
||
defined( 'ABSPATH' ) || exit; // block direct access. | ||
|
||
/** | ||
* A wrapper class for accessing LoggerContext as a singletone. | ||
*/ | ||
class Logger_Context { | ||
/** | ||
* Sets a context value. | ||
* | ||
* @param string $key The key to set. | ||
* @param string|int|float|bool|null $value The value to set. Null removes value. | ||
* | ||
* @return void | ||
*/ | ||
public static function set_value( $key, $value ) { | ||
wcpay_get_container()->get( InternalLoggerContext::class )->set_value( $key, $value ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing to do with this PR in particular, but when we started the re-engineering project, and added
src
with the DI container, I was really hoping that we'd be able to refactor the whole plugin to work that way. Thus this feels like a hack, but I understand it is necessary.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't aware about it, but sounds interesting. I think we way
src
is made to work is much easier to follow than the long lists ofinclude
orrequire
operators in the other parts of plugin code.