tinylog-org / tinylog

tinylog is a lightweight logging framework for Java, Kotlin, Scala, and Android
https://tinylog.org
Apache License 2.0
684 stars 83 forks source link

Add ability to output all keys and values in thread context (v3.0 branch) #718

Closed rhanneken closed 3 months ago

rhanneken commented 3 months ago

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/v3/ has to be updated:

tinylog-org/website#196

Definition of Done

Agreements

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 97.33%. Comparing base (22549cf) to head (38f212d).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## v3.0 #718 +/- ## ========================================= Coverage 97.32% 97.33% - Complexity 1926 1933 +7 ========================================= Files 170 172 +2 Lines 4152 4163 +11 Branches 400 401 +1 ========================================= + Hits 4041 4052 +11 Misses 54 54 Partials 57 57 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

rhanneken commented 3 months ago

What do you think about splitting the logic into two different placeholders? One placeholder for the old logic (outputting the value for a key) and another new placeholder for outputting all thread context entries.

That's a good idea, and I've implemented your suggestion. Let me know what you think.

rhanneken commented 3 months ago

I found just two last minors.

I've addressed them in my latest commit. Let me know what you think.

pmwmedia commented 3 months ago

Thank you for your quick commit. I'm happy to merge the PR :)