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

Support for Timestamp with nanosecond precision (logback 1.3+) #833

Merged
merged 2 commits into from
Aug 14, 2022

Conversation

brenuart
Copy link
Collaborator

Leverage the new ILoggingEvent#getInstant() method introduced in Logback 1.3 to provide timestamp with nanoseconds precision.

closes #829

* Detect at runtime which version of Logback ins used.
If version 1.3, get timestamp by calling the new  `ILoggingEvent#getInstant()` method which provides nanoseconds precision.
If version before 1.3, get the timestamp by calling the older `IloggingEvent#getTimeStamp()` method which gives only milliseconds precision.

* Use an Instant internally whatever version of Logback is used. Adapt TimestampJsonProvider and the associated FastIOSTimestampFormatter to accept Instant with nano precision instead of a long millis.
@brenuart brenuart changed the title Gh829 timestamp nanos gh829 timestamp nanos Aug 14, 2022
@codecov
Copy link

codecov bot commented Aug 14, 2022

Codecov Report

Merging #833 (b681f4e) into main (d7e48a2) will decrease coverage by 0.07%.
The diff coverage is 88.33%.

@@             Coverage Diff              @@
##               main     #833      +/-   ##
============================================
- Coverage     70.97%   70.90%   -0.08%     
- Complexity     1255     1258       +3     
============================================
  Files           167      168       +1     
  Lines          4807     4816       +9     
  Branches        498      502       +4     
============================================
+ Hits           3412     3415       +3     
- Misses         1150     1153       +3     
- Partials        245      248       +3     
Impacted Files Coverage Δ
...nt/LoggingEventFormattedTimestampJsonProvider.java 50.00% <33.33%> (-50.00%) ⬇️
...n/java/net/logstash/logback/util/LogbackUtils.java 40.00% <40.00%> (ø)
...posite/AbstractFormattedTimestampJsonProvider.java 71.64% <88.88%> (ø)
...h/logback/composite/FastISOTimestampFormatter.java 95.91% <97.61%> (-0.96%) ⬇️
...ent/AccessEventFormattedTimestampJsonProvider.java 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@brenuart brenuart merged commit d1df73a into main Aug 14, 2022
@brenuart brenuart deleted the gh829-timestamp-nanos branch August 14, 2022 20:41
@philsttr philsttr changed the title gh829 timestamp nanos Support for Timestamp with nanosecond precision (logback 1.3+) Feb 20, 2023
@philsttr philsttr added the warn/behavior-change Breaking change of publicly advertised behavior label Feb 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement warn/behavior-change Breaking change of publicly advertised behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Timestamp with nanosecond precision (logback 1.3.0)
2 participants