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


##########
drivers/syslog/vsyslog.c:
##########
@@ -115,53 +115,54 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, 
FAR va_list *ap)
 
   if (OSINIT_HW_READY())
     {
-#if defined(CONFIG_SYSLOG_TIMESTAMP_REALTIME)
+#  if defined(CONFIG_SYSLOG_TIMESTAMP_REALTIME)
       /* Use CLOCK_REALTIME if so configured */
 
       clock_gettime(CLOCK_REALTIME, &ts);
 
-#else
+#  else
       /* Prefer monotonic when enabled, as it can be synchronized to
        * RTC with clock_resynchronize.
        */
 
       clock_gettime(CLOCK_MONOTONIC, &ts);
-#endif
+#  endif
 
       /* Prepend the message with the current time, if available */
 
-#if defined(CONFIG_SYSLOG_TIMESTAMP_FORMATTED)
-#if defined(CONFIG_SYSLOG_TIMESTAMP_LOCALTIME)
+#  if defined(CONFIG_SYSLOG_TIMESTAMP_FORMATTED)
+#    if defined(CONFIG_SYSLOG_TIMESTAMP_LOCALTIME)
       localtime_r(&ts.tv_sec, &tm);
-#else
+#    else
       gmtime_r(&ts.tv_sec, &tm);
-#endif
-#endif
+#    endif
+#  endif
     }
 
+#  if defined(CONFIG_SYSLOG_TIMESTAMP_FORMATTED)
+  d_ret = strftime(date_buf, CONFIG_SYSLOG_TIMESTAMP_BUFFER,

Review Comment:
   let's remove d_ret and:
   ```
   data_buf[0] = '\0';
   strftime(date_buf, CONFIG_SYSLOG_TIMESTAMP_BUFFER,
            CONFIG_SYSLOG_TIMESTAMP_FORMAT, &tm);
   ```



##########
drivers/syslog/vsyslog.c:
##########
@@ -145,63 +148,108 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, 
FAR va_list *ap)
 #  endif
 #endif
 
+  ret += lib_sprintf(&stream.public,
 #if defined(CONFIG_SYSLOG_COLOR_OUTPUT)
   /* Reset the terminal style. */
 
-  ret = lib_sprintf(&stream.public, "\e[0m");
+  "\e[0m"
 #endif
 
 #ifdef CONFIG_SYSLOG_TIMESTAMP
 #  if defined(CONFIG_SYSLOG_TIMESTAMP_FORMATTED)
 #    if defined(CONFIG_SYSLOG_TIMESTAMP_FORMAT_MICROSECOND)
-  ret += lib_sprintf(&stream.public, "[%*s.%06ld] ",
-                    d_ret, date_buf, ts.tv_nsec / NSEC_PER_USEC);
+    "[%*s.%06ld] "
 #    else
-  ret += lib_sprintf(&stream.public, "[%*s] ", d_ret, date_buf);
+    "[%*s] "
 #    endif
 #  else
-  ret += lib_sprintf(&stream.public, "[%5jd.%06ld] ",
-                    (uintmax_t)ts.tv_sec, ts.tv_nsec / NSEC_PER_USEC);
+    "[%5jd.%06ld] "
 #  endif
 #endif
 
 #if defined(CONFIG_SMP)
-  ret += lib_sprintf(&stream.public, "[CPU%d] ", up_cpu_index());
+    "[CPU%d] "
 #endif
 
 #if defined(CONFIG_SYSLOG_PROCESSID)
   /* Prepend the Thread ID */
 
-  ret += lib_sprintf(&stream.public, "[%2d] ", gettid());
+  "[%2d] "
 #endif
 
 #if defined(CONFIG_SYSLOG_COLOR_OUTPUT)
   /* Set the terminal style according to message priority. */
 
-  ret += lib_sprintf(&stream.public, "%s", g_priority_color[priority]);
+  "%s"
 #endif
 
 #if defined(CONFIG_SYSLOG_PRIORITY)
   /* Prepend the message priority. */
 
-  ret += lib_sprintf(&stream.public, "[%6s] ", g_priority_str[priority]);
+  "[%6s] "
 #endif
 
 #if defined(CONFIG_SYSLOG_PREFIX)
   /* Prepend the prefix, if available */
 
-  ret += lib_sprintf(&stream.public, "[%s] ", CONFIG_SYSLOG_PREFIX_STRING);
+  "[%s] "
+#endif
+#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_SYSLOG_PROCESS_NAME)
+  /* Prepend the thread name */
+
+  "%s: "
+#endif
+  "%pV"
+
+#ifdef CONFIG_SYSLOG_TIMESTAMP
+#  if defined(CONFIG_SYSLOG_TIMESTAMP_FORMATTED)
+#    if defined(CONFIG_SYSLOG_TIMESTAMP_FORMAT_MICROSECOND)
+  , d_ret, date_buf, ts.tv_nsec / NSEC_PER_USEC
+#    else
+  , d_ret, date_buf
+#    endif
+#  else
+  , (uintmax_t)ts.tv_sec, ts.tv_nsec / NSEC_PER_USEC
+#  endif
+#endif
+
+#if defined(CONFIG_SMP)
+  , up_cpu_index()
+#endif
+
+#if defined(CONFIG_SYSLOG_PROCESSID)
+  /* Prepend the Thread ID */
+
+  , (int)gettid()
+#endif
+
+#if defined(CONFIG_SYSLOG_COLOR_OUTPUT)
+  /* Set the terminal style according to message priority. */
+
+  , g_priority_color[priority]
+#endif
+
+#if defined(CONFIG_SYSLOG_PRIORITY)
+  /* Prepend the message priority. */
+
+  , g_priority_str[priority]
+#endif
+
+#if defined(CONFIG_SYSLOG_PREFIX)
+  /* Prepend the prefix, if available */
+
+  , CONFIG_SYSLOG_PREFIX_STRING
 #endif
 
 #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_SYSLOG_PROCESS_NAME)
   /* Prepend the thread name */
 
-  ret += lib_sprintf(&stream.public, "%s: ", tcb != NULL ? tcb->name : 
"(null)");
+  , tcb != NULL ? tcb->name : "(null)"
 #endif
 
   /* Generate the output */
 
-  ret += lib_vsprintf(&stream.public, fmt, *ap);
+  , &vaf);
 
   if (stream.last_ch != '\n')

Review Comment:
   add:
   ret++



##########
drivers/syslog/vsyslog.c:
##########
@@ -145,63 +148,108 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, 
FAR va_list *ap)
 #  endif
 #endif
 
+  ret += lib_sprintf(&stream.public,

Review Comment:
   ret =



##########
drivers/syslog/vsyslog.c:
##########
@@ -145,63 +148,108 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, 
FAR va_list *ap)
 #  endif
 #endif
 
+  ret += lib_sprintf(&stream.public,
 #if defined(CONFIG_SYSLOG_COLOR_OUTPUT)
   /* Reset the terminal style. */
 
-  ret = lib_sprintf(&stream.public, "\e[0m");
+  "\e[0m"

Review Comment:
   let's algin all args to &stream.public



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