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

Add ability to output all keys and values in thread context #708

Merged
merged 2 commits into from
Apr 4, 2024

Conversation

rhanneken
Copy link
Contributor

Description

The keys in a thread context can differ for different code paths. It would be good if one could log whatever keys and values exist in the thread context without specifying all possible keys in the logging configuration.

This change modifies the context placeholder so that it can be used without specifying a key. When no key is specified, all keys and their values are sent to the output.

Linked website pull request, if the documention of https://tinylog.org/v2/ has to be updated:

tinylog-org/website#188

Definition of Done

  • I read contributing.md
  • There are no TODOs left in the code
  • Code style follows the tinylog standard
  • All classes and methods have Javadoc
  • Changes are covered by JUnit tests including edge cases, errors, and exception handling
  • Maven build works including compiling, tests, and checks (mvn verify)
  • Changes are committed by a verified email address that is assigned to the GitHub account (https://github.com/settings/emails)
  • Documentation on the tinylog website is up-to-date or updated by a pull request to the repository tinylog-org/website

Agreements

  • I agree that my changes will be published under the terms of the Apache License 2.0 (mandatory)
  • I agree that my GitHub user name will be published in the release notes (optional)

The keys in a thread context can differ for different code paths. It
would be good if one could log whatever keys and values exist in the
thread context without specifying all possible keys in the logging
configuration.

This change modifies the "context" placeholder so that it can be used
without specifying a key. When no key is specified, all keys and their
values are sent to the output.
Copy link

codecov bot commented Mar 25, 2024

Codecov Report

Attention: Patch coverage is 92.85714% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 94.25%. Comparing base (eccac76) to head (848f1f5).

Files Patch % Lines
.../java/org/tinylog/pattern/FormatPatternParser.java 66.66% 0 Missing and 1 partial ⚠️
...n/java/org/tinylog/pattern/ThreadContextToken.java 96.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               v2.7     #708      +/-   ##
============================================
- Coverage     94.27%   94.25%   -0.02%     
- Complexity     2833     2838       +5     
============================================
  Files           149      149              
  Lines          5484     5502      +18     
  Branches        725      727       +2     
============================================
+ Hits           5170     5186      +16     
  Misses          176      176              
- Partials        138      140       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@pmwmedia pmwmedia left a comment

Choose a reason for hiding this comment

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

Thank you for your commit! It looks great so far :) I have just three minor improvement suggestions.

A previous commit introduced an ehancement allowing the user to output
all thread context keys and values by using the "context" placeholder
without specifying a key. This commit addresses feedback from a review
of that code: notably, the output is now sorted alphabetically by key,
and unit test code coverage is improved.
@rhanneken
Copy link
Contributor Author

@pmwmedia Thanks for your feedback! I've made some new changes. Let me know if I got it right.

@pmwmedia pmwmedia changed the base branch from v2.7 to v2.8 April 4, 2024 01:23
@pmwmedia pmwmedia merged commit 1ed9f33 into tinylog-org:v2.8 Apr 4, 2024
2 checks passed
@pmwmedia
Copy link
Member

pmwmedia commented Apr 4, 2024

Thank you very much! I will publish it together with tinylog 2.8.

@rhanneken
Copy link
Contributor Author

Great! Do you need me to make an equivalent change to the v3.0 branch?

@pmwmedia
Copy link
Member

pmwmedia commented Apr 4, 2024

I would be very happy about a PR for the v3.0 branch :)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants