fjpanag commented on a change in pull request #2621:
URL: https://github.com/apache/incubator-nuttx/pull/2621#discussion_r557386693



##########
File path: drivers/syslog/vsyslog.c
##########
@@ -132,8 +137,25 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR 
va_list *ap)
 #if defined(CONFIG_SYSLOG_TIMESTAMP)
   /* Pre-pend the message with the current time, if available */
 
+#if defined(CONFIG_SYSLOG_TIMESTAMP_FORMATTED)
+  time = ts.tv_sec;
+#if defined(CONFIG_SYSLOG_TIMESTAMP_LOCALTIME)
+  localtime_r(&time, &tm);
+#else
+  gmtime_r(&time, &tm);
+#endif
+
+  ret = strftime(date_buf, CONFIG_SYSLOG_TIMESTAMP_BUFFER,
+                 CONFIG_SYSLOG_TIMESTAMP_FORMAT, &tm);
+
+  if (ret > 0)
+    {
+      ret = lib_sprintf(&stream.public, "[%s] ", date_buf);

Review comment:
       I think that this is not correct. It will break the formatting in may 
cases.  
   For example, with `"%H:%M:%S %d %h"` you get:  
   `[13:11:27 14 Jan.035468]`, which is at least ugly.
   
   Or  `"%H:%M"`... It will create confusion between seconds and nanoseconds...
   
   I am opposed to making any assumptions on the date format, and altering the 
formatting that the user selected.
   
   ---
   
   If nanosecond accuracy is so important, I would suggest to add another 
Kconfig option regarding whether nanoseconds shall be appended after the 
formatted date.  
   And possibly have something:  
   `[13:11:27 14 Jan] [035468]`
    
   What do you think?




----------------------------------------------------------------
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.

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


Reply via email to