diff --git a/drivers/syslog/Kconfig b/drivers/syslog/Kconfig index 93651f189a..a098bf6aba 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 893a79ab47..d2bb5c1d20 100644 --- a/drivers/syslog/vsyslog.c +++ b/drivers/syslog/vsyslog.c @@ -50,6 +50,18 @@ #include #include +/**************************************************************************** + * 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 */