xiaoxiang781216 commented on code in PR #16493:
URL: https://github.com/apache/nuttx/pull/16493#discussion_r2134915601


##########
drivers/syslog/vsyslog.c:
##########
@@ -253,6 +306,91 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR 
va_list *ap)
 
 #endif /* CONFIG_SYSLOG_COLOR_OUTPUT || CONFIG_SYSLOG_TIMESTAMP || ... */
 
+  /* Output RFC5424 compatible syslog string if that's what the user
+   * selected.
+   */
+
+#if defined(CONFIG_SYSLOG_RFC5424)
+
+  /* Output the RFC5424 header */
+
+  ret = lib_sprintf_internal(
+      &stream.common,
+
+      /* Start of format string */
+
+      "<%d>"         /* PRI */
+      "1 "           /* VERSION */
+
+      /* End of format string */
+
+#ifdef CONFIG_SYSLOG_TIMESTAMP
+      "%s.%06ldZ " /* TIMESTAMP */
+#else
+      NILVALUE_SPACE /* NO TIMESTAMP */
+#endif
+      NILVALUE_SPACE /* TODO: HOSTNAME */
+#ifdef CONFIG_SYSLOG_PROCESS_NAME
+      "%s " /* APPNAME */
+#else
+      NILVALUE_SPACE /* NO APPNAME */
+#endif
+#ifdef CONFIG_SYSLOG_PROCESSID
+      "%d " /* PROCID */
+#else
+      NILVALUE_SPACE /* NO PROCID */
+#endif
+      NILVALUE_SPACE /* TODO: MSGID */
+#if !HAVE_RFC5424_SDATA
+      NILVALUE_SPACE /* Empty structured data, print the NILVALUE here to
+                      * save `libsprintf` call */
+#endif
+      /* Beginning of formatted arguments */
+
+      , priority /* PRIVAL */
+#ifdef CONFIG_SYSLOG_TIMESTAMP
+      , date_buf, ts.tv_nsec / NSEC_PER_USEC /* TIMESTAMP */
+#endif
+      /* TODO: HOSTNAME */

Review Comment:
   call gethostname



##########
drivers/syslog/vsyslog.c:
##########
@@ -253,6 +306,91 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR 
va_list *ap)
 
 #endif /* CONFIG_SYSLOG_COLOR_OUTPUT || CONFIG_SYSLOG_TIMESTAMP || ... */
 
+  /* Output RFC5424 compatible syslog string if that's what the user
+   * selected.
+   */
+
+#if defined(CONFIG_SYSLOG_RFC5424)

Review Comment:
   can we move all rfc5424 related code to the separated function instead 
mixing in the current code base? we can even add a new vsyslog_rfc5424.c and 
select from makefile.



##########
drivers/syslog/Kconfig:
##########
@@ -140,11 +140,35 @@ config SYSLOG_INTBUFSIZE
 
 comment "Formatting options"
 
+config SYSLOG_RFC5424
+       bool "RFC5424 syslog protocol"
+       default n
+       ---help---
+               Causes syslog logs to follow RFC 5424 (syslog protocol).
+
+if SYSLOG_RFC5424
+
+comment "RFC5424 options"
+
+config SYSLOG_RFC5424_TIMEQUALITY
+       bool "timeQuality structured data"
+       depends on SYSLOG_TIMESTAMP
+       default n
+       ---help---
+               Enables the RFC 5424 'timeQuality' structured data element, 
which describes the
+               quality of the timestamp sent.
+
+endif # SYSLOG_RFC5424
+
 config SYSLOG_TIMESTAMP
-       bool "Prepend timestamp to syslog message"
+       bool "Timestamp in syslog message"
+       select SYSLOG_TIMESTAMP_REALTIME if SYSLOG_RFC5424

Review Comment:
   rfc5424 has the fix format, so it's better to decouple SYSLOG_RFC5424 from 
the rest config.



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