This is an automated email from the ASF dual-hosted git repository. xiaoxiang 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 946443e Added printing of log priority in syslog. 946443e is described below commit 946443e190f3b42306364ac1dbac1adb932f19e6 Author: Fotis Panagiotopoulos <fotis400.m...@gmail.com> AuthorDate: Thu Jan 14 17:43:20 2021 +0200 Added printing of log priority in syslog. --- drivers/syslog/Kconfig | 6 ++++++ drivers/syslog/vsyslog.c | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/drivers/syslog/Kconfig b/drivers/syslog/Kconfig index 93651f1..a098bf6 100644 --- a/drivers/syslog/Kconfig +++ b/drivers/syslog/Kconfig @@ -142,6 +142,12 @@ config SYSLOG_TIMESTAMP_BUFFER ---help--- Buffer size to store syslog formatted timestamps. +config SYSLOG_PRIORITY + bool "Prepend priority to syslog message" + default n + ---help--- + Prepend log priority (severity) 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 893a79a..d2bb5c1 100644 --- a/drivers/syslog/vsyslog.c +++ b/drivers/syslog/vsyslog.c @@ -51,6 +51,18 @@ #include <nuttx/syslog/syslog.h> /**************************************************************************** + * Private Data + ****************************************************************************/ + +#if defined(CONFIG_SYSLOG_PRIORITY) +static FAR const char * g_priority_str[] = + { + "EMERG", "ALERT", "CRIT", "ERROR", + "WARN", "NOTICE", "INFO", "DEBUG" + }; +#endif + +/**************************************************************************** * Public Functions ****************************************************************************/ @@ -160,6 +172,10 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap) ret = 0; #endif +#if defined(CONFIG_SYSLOG_PRIORITY) + ret += lib_sprintf(&stream.public, "[%6s] ", g_priority_str[priority]); +#endif + #if defined(CONFIG_SYSLOG_PREFIX) /* Pre-pend the prefix, if available */