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 support for logging with multiple tags #213

Merged
merged 2 commits into from Jul 9, 2021
Merged

Add support for logging with multiple tags #213

merged 2 commits into from Jul 9, 2021

Conversation

kahgoh
Copy link
Contributor

@kahgoh kahgoh commented Jun 16, 2021

Description

Linked issue: #201

This change allows a single TaggedLogger to log to multiple tags, instead of having to create individual logger for each tag.

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

Additions or amendments for the public documentation:

  • Tags will need to be updated with the addition of the new tags method.

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)

@pmwmedia
Copy link
Member

What is the current status? When can I do the review?

@kahgoh
Copy link
Contributor Author

kahgoh commented Jun 30, 2021

Sorry, its taking me a while. I'm still working updating the Scala API side.

@pmwmedia
Copy link
Member

pmwmedia commented Jul 1, 2021

@kahgoh Thanks for the status update :)

@kahgoh
Copy link
Contributor Author

kahgoh commented Jul 5, 2021

I've pushed in the Scala API changes and think its ready for review now. I'll come back to add something for the documentation later when I get the chance.

@kahgoh kahgoh marked this pull request as ready for review July 5, 2021 13:16
@codecov
Copy link

codecov bot commented Jul 5, 2021

Codecov Report

Merging #213 (1b84437) into v2.4 (e1019aa) will increase coverage by 0.05%.
The diff coverage is 94.05%.

Impacted file tree graph

@@             Coverage Diff              @@
##               v2.4     #213      +/-   ##
============================================
+ Coverage     94.33%   94.39%   +0.05%     
- Complexity     2463     2638     +175     
============================================
  Files           128      131       +3     
  Lines          4699     5047     +348     
  Branches        529      655     +126     
============================================
+ Hits           4433     4764     +331     
- Misses          146      156      +10     
- Partials        120      127       +7     
Impacted Files Coverage Δ
...g/tinylog/writers/AbstractFormatPatternWriter.java 100.00% <ø> (+2.22%) ⬆️
...cala/src/main/scala/org/tinylog/scala/Logger.scala 88.23% <83.33%> (-3.44%) ⬇️
.../src/main/java/org/tinylog/writers/JsonWriter.java 88.57% <88.57%> (ø)
...src/main/kotlin/org/tinylog/kotlin/TaggedLogger.kt 95.42% <93.38%> (+0.64%) ⬆️
...og-api/src/main/java/org/tinylog/TaggedLogger.java 96.55% <94.54%> (-0.19%) ⬇️
...a/org/tinylog/writers/AbstractFileBasedWriter.java 97.43% <97.43%> (ø)
...org/tinylog/slf4j/TinylogSlf4jServiceProvider.java 100.00% <100.00%> (ø)
...otlin/src/main/kotlin/org/tinylog/kotlin/Logger.kt 96.00% <100.00%> (+0.83%) ⬆️
...rc/main/scala/org/tinylog/scala/TaggedLogger.scala 100.00% <100.00%> (ø)
tinylog-api/src/main/java/org/tinylog/Logger.java 96.51% <100.00%> (+0.26%) ⬆️
... and 11 more

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 5679944...1b84437. Read the comment docs.

@pmwmedia
Copy link
Member

pmwmedia commented Jul 5, 2021

Thank you very much for your commit :) I'm going to review it. Could you fix one compile error in the mean time?

/home/runner/work/tinylog/tinylog/tinylog-api/src/main/java/org/tinylog/Logger.java:[92,47] diamond operator is not supported in -source 1.6

For Android support, the source code still needs to be Java 6 compatible.

@pmwmedia
Copy link
Member

pmwmedia commented Jul 5, 2021

I have just finished my review. Your code looks very well! I have found just a few minors to change.

@kahgoh
Copy link
Contributor Author

kahgoh commented Jul 8, 2021

Thanks for the feedback and review! I have just finished and pushed the changes.

class TaggedLogger internal constructor(private val tag: String?) {
class TaggedLogger internal constructor(private val tags: Set<String?>) {

constructor(tag: String?) : this(setOf(tag))
Copy link
Member

Choose a reason for hiding this comment

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

Do we really still need this constructor? If yes, could you declare the constructor as internal? I want to prohibit that users create their own instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, that constructor isn't needed anymore. I'll remove it 😉

@pmwmedia
Copy link
Member

pmwmedia commented Jul 8, 2021

Thank you very much for your changes! I could found only one last minor.

Could to push potential further changes as new separate commits? It would make the review easier for me :)

I really like your pull request! You had to change a lot of code. However, your changes are easily comprehensible.

This simplifies the class and prevents users from initiating their own
instances (they should be obtaining instances via the Logger).
@kahgoh
Copy link
Contributor Author

kahgoh commented Jul 9, 2021

I've just pushed the change to remove the internal constructor

@pmwmedia pmwmedia merged commit 26dc4aa into tinylog-org:v2.4 Jul 9, 2021
@pmwmedia
Copy link
Member

pmwmedia commented Jul 9, 2021

Thank you for your great work! I have merged your pull request with pleasure.

@github-actions
Copy link

github-actions bot commented Oct 9, 2022

This closed pull request has been locked automatically. However, please feel free to file an issue or create a new pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 9, 2022
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