syslog: CONFIG_CLOCK_MONOTONIC
This commit is contained in:
parent
0113b0db95
commit
9fc5f44ef6
|
@ -116,6 +116,15 @@ config SYSLOG_TIMESTAMP
|
|||
---help---
|
||||
Prepend timestamp to syslog message.
|
||||
|
||||
config SYSLOG_TIMESTAMP_REALTIME
|
||||
bool "Use wall-clock for syslog timestamp"
|
||||
default n
|
||||
depends on SYSLOG_TIMESTAMP
|
||||
---help---
|
||||
Use wall-clock (CLOCK_REALTIME) for timestamp. By default,
|
||||
CLOCK_MONOTONIC, if enabled, will be used or the system timer
|
||||
is not.
|
||||
|
||||
config SYSLOG_SERIAL_CONSOLE
|
||||
bool
|
||||
default n
|
||||
|
|
|
@ -82,13 +82,21 @@ int _vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap)
|
|||
ret = -EAGAIN;
|
||||
if (OSINIT_HW_READY())
|
||||
{
|
||||
#if defined(CONFIG_SYSLOG_TIMESTAMP_REALTIME)
|
||||
/* Use CLOCK_REALTIME if so configured */
|
||||
|
||||
ret = clock_gettime(CLOCK_REALTIME, &ts);
|
||||
|
||||
#elif defined(CONFIG_CLOCK_MONOTONIC)
|
||||
/* Prefer monotonic when enabled, as it can be synchronized to
|
||||
* RTC with clock_resynchronize.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
||||
ret = clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
|
||||
#else
|
||||
/* Otherwise, fall back to the system timer */
|
||||
|
||||
ret = clock_systimespec(&ts);
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue