This is an automated email from the ASF dual-hosted git repository.

btashton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new efe236b  drivers/syslog: Prepend Process ID to syslog message
efe236b is described below

commit efe236ba843dcd0dd93f296949df719ad8c114bf
Author: chao.an <anc...@xiaomi.com>
AuthorDate: Sat Jan 16 19:24:53 2021 +0800

    drivers/syslog: Prepend Process ID to syslog message
    
    Signed-off-by: chao.an <anc...@xiaomi.com>
---
 drivers/syslog/Kconfig   | 6 ++++++
 drivers/syslog/vsyslog.c | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/drivers/syslog/Kconfig b/drivers/syslog/Kconfig
index 461a32c..7664a63 100644
--- a/drivers/syslog/Kconfig
+++ b/drivers/syslog/Kconfig
@@ -154,6 +154,12 @@ config SYSLOG_PRIORITY
        ---help---
                Prepend log priority (severity) to syslog message.
 
+config SYSLOG_PROCESSID
+       bool "Prepend Process ID to syslog message"
+       default n
+       ---help---
+               Prepend Process ID to syslog message.
+
 config SYSLOG_PREFIX
        bool "Prepend prefix to syslog message"
        default n
diff --git a/drivers/syslog/vsyslog.c b/drivers/syslog/vsyslog.c
index 728db13..b4441df 100644
--- a/drivers/syslog/vsyslog.c
+++ b/drivers/syslog/vsyslog.c
@@ -176,6 +176,12 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR 
va_list *ap)
   ret += lib_sprintf(&stream.public, "[%6s] ", g_priority_str[priority]);
 #endif
 
+#if defined(CONFIG_SYSLOG_PROCESSID)
+  /* Pre-pend the Process ID */
+
+  ret += lib_sprintf(&stream.public, "[%2d] ", (int)getpid());
+#endif
+
 #if defined(CONFIG_SYSLOG_COLOR_OUTPUT)
   /* Set the terminal style according to message priority. */
 

Reply via email to