mirror of
https://github.com/espressif/openthread.git
synced 2026-08-17 07:59:51 +00:00
[logging] add CONFIG_LOG_PREPEND_UPTIME to prepend uptime to the log (#6968)
This commit adds `OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME` config to prepend the current uptime (as "[x days] hh::mm::ss.mmmm") to the OpenThread log messages.
This commit is contained in:
committed by
Jonathan Hui
parent
ca3830fac2
commit
6f7684ed8b
@@ -43,7 +43,15 @@
|
||||
* It is reasonable to only enable the debug uart and not enable logs to the DEBUG uart.
|
||||
*/
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_DEBUG_UART) && (!OPENTHREAD_CONFIG_ENABLE_DEBUG_UART)
|
||||
#error OPENTHREAD_CONFIG_ENABLE_DEBUG_UART_LOG requires OPENTHREAD_CONFIG_ENABLE_DEBUG_UART
|
||||
#error "OPENTHREAD_CONFIG_ENABLE_DEBUG_UART_LOG requires OPENTHREAD_CONFIG_ENABLE_DEBUG_UART"
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME && !OPENTHREAD_CONFIG_UPTIME_ENABLE
|
||||
#error "OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME requires OPENTHREAD_CONFIG_UPTIME_ENABLE"
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME && OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
|
||||
#error "OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME is not supported under OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -56,6 +64,11 @@ static void Log(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aForma
|
||||
{
|
||||
ot::String<OPENTHREAD_CONFIG_LOG_MAX_SIZE> logString;
|
||||
|
||||
#if OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME
|
||||
ot::Uptime::UptimeToString(ot::Instance::Get().Get<ot::Uptime>().GetUptime(), logString);
|
||||
logString.Append(" ");
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
|
||||
VerifyOrExit(otLoggingGetLevel() >= aLogLevel);
|
||||
#endif
|
||||
|
||||
@@ -339,6 +339,16 @@
|
||||
#define OPENTHREAD_CONFIG_LOG_DNS 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME
|
||||
*
|
||||
* Define as 1 to prepend the current uptime to all log messages.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME
|
||||
#define OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL
|
||||
*
|
||||
|
||||
@@ -288,13 +288,21 @@
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE 1
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME
|
||||
*
|
||||
* Define as 1 to prepend the current uptime to all log messages.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME 1
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL
|
||||
*
|
||||
* Define to prepend the log level to all log messages
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL 0
|
||||
#define OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL 1
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_LOG_PREPEND_REGION
|
||||
@@ -302,7 +310,7 @@
|
||||
* Define to prepend the log region to all log messages
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_LOG_PREPEND_REGION 0
|
||||
#define OPENTHREAD_CONFIG_LOG_PREPEND_REGION 1
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_LOG_SUFFIX
|
||||
|
||||
Reference in New Issue
Block a user