-
Notifications
You must be signed in to change notification settings - Fork 20
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
feat: Implement Default Logging Hook #308
base: main
Are you sure you want to change the base?
feat: Implement Default Logging Hook #308
Conversation
Hey @kylejuliandev, thanks for the PR. Could you please sign off your commits? The CNCF requires you to acknowledge that you're willing and able to donate this code. To add your Signed-off-by line to every commit in this branch:
Thanks! |
d5d08f7
to
b4b4765
Compare
Hi @beeme1mr! No worries, I've pushed up the signed commits now. Happy to donate this code, although it is incomplete at the moment. Will resume and get some unit tests in. Logging semantics (log IDs, log levels, content, etc...) are still left to determine - although I have tried to adhere to the spec |
Hey, @kylejuliandev! Great work on this PR; everything seems good to go. As you pointed out, however, a few unit tests are missing to get this PR out. Would you like some help? Just a tiny suggestion: I would move the |
Thanks for the reminder @askpt - I completely forgot about this, my bad! I have added some unit tests now to cover the LoggingHook. I suspect another task may include updating the README for guidance on how to use the hook. |
0f48130
to
dff409c
Compare
Signed-off-by: Kyle Julian <[email protected]>
Signed-off-by: Kyle Julian <[email protected]>
…th string.IsNullOrEmpty Signed-off-by: Kyle Julian <[email protected]>
Signed-off-by: Kyle Julian <[email protected]>
Signed-off-by: Kyle Julian <[email protected]>
dff409c
to
ea2b393
Compare
Yes please! Here's an example from the Java SDK. Thanks https://github.com/open-feature/java-sdk?tab=readme-ov-file#logging-hook |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #308 +/- ##
==========================================
+ Coverage 85.49% 86.19% +0.69%
==========================================
Files 38 39 +1
Lines 1517 1608 +91
Branches 154 173 +19
==========================================
+ Hits 1297 1386 +89
+ Misses 188 186 -2
- Partials 32 36 +4 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Kyle Julian <[email protected]>
Signed-off-by: Kyle Julian <[email protected]>
Signed-off-by: Kyle Julian <[email protected]>
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.
Added a few comments.
src/OpenFeature/Hooks/LoggingHook.cs
Outdated
if (logger == null) throw new ArgumentNullException(nameof(logger)); | ||
|
||
this._logger = logger; |
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.
if (logger == null) throw new ArgumentNullException(nameof(logger)); | |
this._logger = logger; | |
this._logger = logger ?? throw new ArgumentNullException(nameof(logger)); |
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.
Good shout! I've added the null-coalesing operator inplace of doing a seperate if null check
src/OpenFeature/Hooks/LoggingHook.cs
Outdated
stringBuilder.Append("Domain:"); | ||
stringBuilder.Append(this._domain); | ||
stringBuilder.Append(Environment.NewLine); |
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.
This code can be simplified. The same applies for the next lines.
stringBuilder.Append("Domain:"); | |
stringBuilder.Append(this._domain); | |
stringBuilder.Append(Environment.NewLine); | |
stringBuilder.AppendLine($"Domain: {this._domain}"); |
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 forgot about this method on StringBuilder - I've switched to stringBuilder.AppendLine
instead of manually Appending Environment.NewLine
* Adopt StringBuilder.AppendLine instead of manually referring to Environment.NewLine * Use null-coalescing operator inplace of adding a if null check Signed-off-by: Kyle Julian <[email protected]>
* Suppress ConfigureAwait warnings in unit test class Signed-off-by: Kyle Julian <[email protected]>
This PR
Related Issues
Fixes #299
Notes
Follow-up Tasks
How to test