1
0
Fork 0
forked from nuttx/nuttx-update

Added printing of log priority in syslog.

This commit is contained in:
Fotis Panagiotopoulos 2021-01-14 17:43:20 +02:00 committed by Xiang Xiao
parent 7e3d4a5f29
commit 946443e190
2 changed files with 22 additions and 0 deletions

View file

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

View file

@ -50,6 +50,18 @@
#include <nuttx/streams.h>
#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 */