pkarashchenko commented on a change in pull request #5853:
URL: https://github.com/apache/incubator-nuttx/pull/5853#discussion_r835897829



##########
File path: drivers/syslog/vsyslog.c
##########
@@ -130,7 +130,8 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR 
va_list *ap)
 
   if (ret > 0)
     {
-      ret = lib_sprintf(&stream.public, "[%s] ", date_buf);
+      ret = lib_sprintf(&stream.public, "[%s.%06ld] ",
+                        date_buf, ts.tv_nsec / 1000);

Review comment:
       I think there is no easy solution for this. I will write few possible 
cases that comes in my mind, then we can discuss this based on opinions from 
other reviewers:
   1. Add `clock_printf()` API that will work similar to `strftime()`, but will 
get `struct timespec` as an input and will implement additional print format 
(like `%f` in python variant of `strftime()`). The standard `strftime` can be 
reused for all parts except `%f` so probably API will be not too "heavy".
   2. Remove `CONFIG_SYSLOG_TIMESTAMP_FORMAT` config option and hard-code 
format to `"%e/%m/%y %H:%M:%S"` and keep your variant with `[%s.%06ld]`.
   3. Parse `CONFIG_SYSLOG_TIMESTAMP_FORMAT` here and identify where `%S` is 
placed and if it is present then generate new format string that will be 
`"%e/%m/%y %H:%M:%S.value"` like with already pre-printed value of microseconds.
   4. other variant.




-- 
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: commits-unsubscr...@nuttx.apache.org

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


Reply via email to