Skip to content

Commit 8f634a8

Browse files
GregoryComerfacebook-github-bot
authored andcommitted
Add EXECUTORCH_LOG_LEVEL option to CMake (#2532)
Summary: Add a CMake setting (EXECUTORCH_LOG_LEVEL) to set ET_MIN_LOG_LEVEL. Must be one of Debug, Info, Error, or Fatal (case-insensitive). bypass-github-export-checks Pull Request resolved: #2532 Test Plan: Ran xnn_executor_runner with EXECUTORCH_LOG_LEVEL set to "debug", "Debug", "info", and "bad". Log level and build messages behaved as expected. Reviewed By: digantdesai Differential Revision: D55147165 Pulled By: GregoryComer fbshipit-source-id: 3bab69948dea4c81cc3e7a46054b62cfb8cc6994
1 parent e3ee6d9 commit 8f634a8

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,24 @@ if(NOT EXECUTORCH_ENABLE_LOGGING)
7777
add_definitions(-DET_LOG_ENABLED=0)
7878
endif()
7979

80+
# Configure log level. Must be one of debug, info, error, fatal.
81+
set(EXECUTORCH_LOG_LEVEL "Info" CACHE STRING
82+
"Build with the given ET_MIN_LOG_LEVEL value")
83+
string(TOLOWER "${EXECUTORCH_LOG_LEVEL}" LOG_LEVEL_LOWER)
84+
if(LOG_LEVEL_LOWER STREQUAL "debug")
85+
add_definitions(-DET_MIN_LOG_LEVEL=Debug)
86+
elseif(LOG_LEVEL_LOWER STREQUAL "info")
87+
add_definitions(-DET_MIN_LOG_LEVEL=Info)
88+
elseif(LOG_LEVEL_LOWER STREQUAL "error")
89+
add_definitions(-DET_MIN_LOG_LEVEL=Error)
90+
elseif(LOG_LEVEL_LOWER STREQUAL "fatal")
91+
add_definitions(-DET_MIN_LOG_LEVEL=Fatal)
92+
else()
93+
message(SEND_ERROR
94+
"Unknown log level \"${EXECUTORCH_LOG_LEVEL}\". Expected one of Debug, " +
95+
"Info, Error, or Fatal.")
96+
endif()
97+
8098
option(EXECUTORCH_ENABLE_PROGRAM_VERIFICATION
8199
"Build with ET_ENABLE_PROGRAM_VERIFICATION"
82100
${_default_release_disabled_options})

build/Utils.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ function(executorch_print_configuration_summary)
3434
message(STATUS " FLATC_EXECUTABLE : ${FLATC_EXECUTABLE}")
3535
message(
3636
STATUS " EXECUTORCH_ENABLE_LOGGING : ${EXECUTORCH_ENABLE_LOGGING}")
37+
message(
38+
STATUS " EXECUTORCH_LOG_LEVEL : ${EXECUTORCH_LOG_LEVEL}")
3739
message(STATUS " EXECUTORCH_ENABLE_PROGRAM_VERIFICATION : "
3840
"${EXECUTORCH_ENABLE_PROGRAM_VERIFICATION}")
3941
message(
@@ -46,6 +48,8 @@ function(executorch_print_configuration_summary)
4648
)
4749
message(
4850
STATUS " REGISTER_EXAMPLE_CUSTOM_OPS : ${REGISTER_EXAMPLE_CUSTOM_OPS}")
51+
message(STATUS " EXECUTORCH_BUILD_EXTENSION_AOT_UTIL : "
52+
"${EXECUTORCH_BUILD_EXTENSION_AOT_UTIL}")
4953
message(STATUS " EXECUTORCH_BUILD_EXTENSION_DATA_LOADER : "
5054
"${EXECUTORCH_BUILD_EXTENSION_DATA_LOADER}")
5155
message(STATUS " EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL : "

0 commit comments

Comments
 (0)