You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2022/11/03 19:20:07 UTC

[GitHub] [kafka] ashmeet13 commented on a diff in pull request #12684: KAFKA-14254; Format timestamps as dates in logs

ashmeet13 commented on code in PR #12684:
URL: https://github.com/apache/kafka/pull/12684#discussion_r1013311309


##########
clients/src/main/java/org/apache/kafka/common/utils/Utils.java:
##########
@@ -1450,4 +1453,15 @@ public static String[] enumOptions(Class<? extends Enum<?>> enumClass) {
                 .toArray(String[]::new);
     }
 
+    /**
+     * Convert time instant to readable string for logging
+     * @param timestamp the timestamp of the instant to be converted.
+     *
+     * @return string value of a given timestamp in the format "yyyy-MM-dd HH:mm:ss,SSS"
+     */
+    public static String toLogDateTimeFormat(long timestamp) {
+        final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss,SSS");

Review Comment:
   Hi @cadonna, I have added the change for this. A few sample logs with the updated datetime format -
   
   ```
   [2022-11-04 00:36:28,517] INFO stream-thread [stream-thread-test-87bf53a8-54f2-485f-a4b6-acdbec0a8b3d-StreamThread-1] Triggering the followup rebalance scheduled for 2022-11-04 00:36:28,511 +05:30. (org.apache.kafka.streams.processor.internals.StreamThread:614)
   ```
   ```
   [2022-11-04 00:46:52,220] INFO stream-thread [] Requesting followup rebalance be scheduled by consumer10 for 2022-11-04 00:56:52,212 +05:30 to probe for caught-up replica tasks. (org.apache.kafka.streams.processor.internals.StreamsPartitionAssignor:960)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org