Squashed commit of the following:
drivers/syslog: Channel configuration. Decouple SYSLOG_SERIAL_CONSOLE and ARCH_LOWPUTC. Since some hardware can output log to the special debug channel not serial. drivers/syslog/vsyslog.c: Support pre-pending a prefix string to log output if enabled. This very useful to identify which cpu send out the log in AMP SoC. drivers/syslog/vsyslog.c: Make timestamp output same as linux kernel. It's very useful if NuttX syslog retarget to Linux syslog.
This commit is contained in:
parent
bd252230ad
commit
1ee6083de3
|
@ -125,6 +125,19 @@ config SYSLOG_TIMESTAMP_REALTIME
|
|||
CLOCK_MONOTONIC, if enabled, will be used or the system timer
|
||||
is not.
|
||||
|
||||
config SYSLOG_PREFIX
|
||||
bool "Prepend prefix to syslog message"
|
||||
default n
|
||||
---help---
|
||||
Prepend prefix to syslog message.
|
||||
|
||||
config SYSLOG_PREFIX_STRING
|
||||
string "Prefix string"
|
||||
depends on SYSLOG_PREFIX
|
||||
default ""
|
||||
---help---
|
||||
The prefix string to be prepend.
|
||||
|
||||
config SYSLOG_SERIAL_CONSOLE
|
||||
bool
|
||||
default n
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SYSLOG_SERIAL_CONSOLE) && defined(CONFIG_ARCH_LOWPUTC)
|
||||
#if defined(CONFIG_ARCH_LOWPUTC)
|
||||
# define HAVE_LOWPUTC
|
||||
#elif !defined(CONFIG_RAMLOG_SYSLOG)
|
||||
# define NEED_LOWPUTC
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#undef HAVE_LOWPUTC
|
||||
#if defined(CONFIG_SYSLOG_SERIAL_CONSOLE) && defined(CONFIG_ARCH_LOWPUTC)
|
||||
#if defined(CONFIG_ARCH_LOWPUTC)
|
||||
# define HAVE_LOWPUTC 1
|
||||
#endif
|
||||
|
||||
|
|
|
@ -131,13 +131,21 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap)
|
|||
#if defined(CONFIG_SYSLOG_TIMESTAMP)
|
||||
/* Pre-pend the message with the current time, if available */
|
||||
|
||||
(void)lib_sprintf(&stream.public, "[%6d.%06d]",
|
||||
(void)lib_sprintf(&stream.public, "[%5d.%06d] ",
|
||||
ts.tv_sec, ts.tv_nsec/1000);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SYSLOG_PREFIX)
|
||||
/* Pre-pend the prefix, if available */
|
||||
|
||||
ret = lib_sprintf(&stream.public, "%s", CONFIG_SYSLOG_PREFIX_STRING);
|
||||
#else
|
||||
ret = 0;
|
||||
#endif
|
||||
|
||||
/* Generate the output */
|
||||
|
||||
ret = lib_vsprintf(&stream.public, fmt, *ap);
|
||||
ret += lib_vsprintf(&stream.public, fmt, *ap);
|
||||
|
||||
#ifdef CONFIG_SYSLOG_BUFFER
|
||||
/* Flush and destroy the syslog stream buffer */
|
||||
|
|
Loading…
Reference in New Issue