diff --git a/arch/arm/src/armv7-m/etm.h b/arch/arm/src/armv7-m/etm.h index 5af02d45d79..eef1ba85d04 100644 --- a/arch/arm/src/armv7-m/etm.h +++ b/arch/arm/src/armv7-m/etm.h @@ -70,7 +70,7 @@ *******************************************************************************************************************************/ /* ETM Register Base Address ***************************************************************************************************/ -#define ETM_BASE +#define ETM_BASE (0xe0041000ul) /* ETM Register Offsets ********************************************************************************************************/ diff --git a/fs/Kconfig b/fs/Kconfig index 0dba7f80a33..78d2fc89cb4 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -75,6 +75,12 @@ config SYSLOG if SYSLOG +config SYSLOG_TIMESTAMP + bool "Prepend timestamp to syslog message" + default y + ---help--- + Prepend timestamp to syslog message. + config SYSLOG_CHAR bool "System log character device support" default y diff --git a/libc/syslog/lib_syslog.c b/libc/syslog/lib_syslog.c index 63441fd9ed6..70e8e13de5f 100644 --- a/libc/syslog/lib_syslog.c +++ b/libc/syslog/lib_syslog.c @@ -42,6 +42,7 @@ #include #include +#include #include #include "syslog/syslog.h" @@ -94,41 +95,85 @@ static inline int vsyslog_internal(FAR const char *fmt, va_list ap) { #if defined(CONFIG_SYSLOG) - struct lib_outstream_s stream; +#elif CONFIG_NFILE_DESCRIPTORS > 0 + struct lib_rawoutstream_s stream; +#elif defined(CONFIG_ARCH_LOWPUTC) + struct lib_outstream_s stream; +#endif +#if defined(CONFIG_SYSLOG_TIMESTAMP) + struct timespec ts; + int ret; + + /* Get the current time */ + + ret = clock_systimespec(&ts); +#endif + +#if defined(CONFIG_SYSLOG) /* Wrap the low-level output in a stream object and let lib_vsprintf * do the work. */ lib_syslogstream((FAR struct lib_outstream_s *)&stream); + +#if defined(CONFIG_SYSLOG_TIMESTAMP) + /* Pre-pend the message with the current time */ + + if (ret == OK) + { + (void)lib_sprintf((FAR struct lib_outstream_s *)&stream, + "[%6d.%06d]", + ts.tv_sec, ts.tv_nsec/1000); + } +#endif + return lib_vsprintf((FAR struct lib_outstream_s *)&stream, fmt, ap); #elif CONFIG_NFILE_DESCRIPTORS > 0 - - struct lib_rawoutstream_s rawoutstream; - /* Wrap the stdout in a stream object and let lib_vsprintf * do the work. */ - lib_rawoutstream(&rawoutstream, 1); - return lib_vsprintf(&rawoutstream.public, fmt, ap); + lib_rawoutstream(&stream, 1); + +#if defined(CONFIG_SYSLOG_TIMESTAMP) + /* Pre-pend the message with the current time */ + + if (ret == OK) + { + (void)lib_sprintf((FAR struct lib_outstream_s *)&stream, + "[%6d.%06d]", + ts.tv_sec, ts.tv_nsec/1000); + } +#endif + + return lib_vsprintf(&stream.public, fmt, ap); #elif defined(CONFIG_ARCH_LOWPUTC) - - struct lib_outstream_s stream; - /* Wrap the low-level output in a stream object and let lib_vsprintf * do the work. */ lib_lowoutstream((FAR struct lib_outstream_s *)&stream); + +#if defined(CONFIG_SYSLOG_TIMESTAMP) + /* Pre-pend the message with the current time */ + + if (ret == OK) + { + (void)lib_sprintf((FAR struct lib_outstream_s *)&stream, + "[%6d.%06d]", + ts.tv_sec, ts.tv_nsec/1000); + } +#endif + return lib_vsprintf((FAR struct lib_outstream_s *)&stream, fmt, ap); -#else +#else /* CONFIG_SYSLOG */ return 0; -#endif +#endif /* CONFIG_SYSLOG */ } /****************************************************************************