Skip to content

Commit

Permalink
[cmake] support setting log level (#5433)
Browse files Browse the repository at this point in the history
  • Loading branch information
bukepo committed Aug 20, 2020
1 parent e438c2e commit d6fb9de
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
14 changes: 14 additions & 0 deletions CMakeLists.txt
Expand Up @@ -103,6 +103,20 @@ if(NOT OT_PLATFORM IN_LIST OT_PLATFORMS)
message(FATAL_ERROR "Platform unknown: ${OT_PLATFORM}")
endif()

set(OT_LOG_LEVEL "" CACHE STRING "set OpenThread log level")
set(OT_LOG_LEVEL_VALUES
"NONE"
"CRIT"
"WARN"
"NOTE"
"INFO"
"DEBG"
)
set_property(CACHE OT_LOG_LEVEL PROPERTY STRINGS ${OT_LOG_LEVEL_VALUES})
if(OT_LOG_LEVEL)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_${OT_LOG_LEVEL}")
endif()

set(OT_LOG_OUTPUT_VALUES
"APP"
"DEBUG_UART"
Expand Down
4 changes: 3 additions & 1 deletion etc/cmake/options.cmake
Expand Up @@ -244,7 +244,9 @@ endif()

option(OT_FULL_LOGS "enable full logs")
if(OT_FULL_LOGS)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_DEBG")
if(NOT OT_LOG_LEVEL)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_DEBG")
endif()
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_API=1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_ARP=1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_BBR=1")
Expand Down
2 changes: 1 addition & 1 deletion script/test
Expand Up @@ -313,7 +313,7 @@ EXAMPLES:
do_package()
{
local builddir
local options=("-DCMAKE_BUILD_TYPE=Release")
local options=("-DCMAKE_BUILD_TYPE=Release" "-DOT_LOG_LEVEL=INFO")

if [[ ${ot_extra_options[*]+x} ]]; then
options+=("${ot_extra_options[@]}")
Expand Down

0 comments on commit d6fb9de

Please sign in to comment.