diff --git a/drivers/syslog/Kconfig b/drivers/syslog/Kconfig index d6c6bbd9b27..30a87feddda 100644 --- a/drivers/syslog/Kconfig +++ b/drivers/syslog/Kconfig @@ -174,6 +174,14 @@ if !SYSLOG_RFC5424 comment "Regular syslog formatting options" +config SYSLOG_TIMESTAMP_MS + bool "Use milliseconds for syslog timestamp" + default n + depends on SYSLOG_TIMESTAMP + ---help--- + Use milliseconds for timestamp. By default, + microsecond will be used. + config SYSLOG_TIMESTAMP_REALTIME bool "Use wall-clock for syslog timestamp" default n diff --git a/drivers/syslog/vsyslog.c b/drivers/syslog/vsyslog.c index 21a1bfe77f5..b930245a95e 100644 --- a/drivers/syslog/vsyslog.c +++ b/drivers/syslog/vsyslog.c @@ -167,7 +167,11 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap) "[%s] " # endif # else +# if defined(CONFIG_SYSLOG_TIMESTAMP_MS) + "[%5ju.%03ld] " +# else "[%5ju.%06ld] " +# endif # endif #endif @@ -211,8 +215,13 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap) , date_buf # endif # else +# if defined(CONFIG_SYSLOG_TIMESTAMP_MS) + , (uintmax_t)ts.tv_sec + , ts.tv_nsec / NSEC_PER_MSEC +# else , (uintmax_t)ts.tv_sec , ts.tv_nsec / NSEC_PER_USEC +# endif # endif #endif