Skip to content

Commit 72ed283

Browse files
committed
move EXECUTORCH_LOG_LEVEL
1 parent 83be7d3 commit 72ed283

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

CMakeLists.txt

+1-21
Original file line numberDiff line numberDiff line change
@@ -108,27 +108,7 @@ if(NOT EXECUTORCH_ENABLE_LOGGING)
108108
add_definitions(-DET_LOG_ENABLED=0)
109109
endif()
110110

111-
# Configure log level. Must be one of debug, info, error, fatal.
112-
set(EXECUTORCH_LOG_LEVEL
113-
"Info"
114-
CACHE STRING "Build with the given ET_MIN_LOG_LEVEL value"
115-
)
116-
string(TOLOWER "${EXECUTORCH_LOG_LEVEL}" LOG_LEVEL_LOWER)
117-
if(LOG_LEVEL_LOWER STREQUAL "debug")
118-
add_definitions(-DET_MIN_LOG_LEVEL=Debug)
119-
elseif(LOG_LEVEL_LOWER STREQUAL "info")
120-
add_definitions(-DET_MIN_LOG_LEVEL=Info)
121-
elseif(LOG_LEVEL_LOWER STREQUAL "error")
122-
add_definitions(-DET_MIN_LOG_LEVEL=Error)
123-
elseif(LOG_LEVEL_LOWER STREQUAL "fatal")
124-
add_definitions(-DET_MIN_LOG_LEVEL=Fatal)
125-
else()
126-
message(
127-
SEND_ERROR
128-
"Unknown log level \"${EXECUTORCH_LOG_LEVEL}\". Expected one of Debug, "
129-
+ "Info, Error, or Fatal."
130-
)
131-
endif()
111+
add_definitions(-DET_MIN_LOG_LEVEL=${ET_MIN_LOG_LEVEL})
132112

133113
option(EXECUTORCH_ENABLE_PROGRAM_VERIFICATION
134114
"Build with ET_ENABLE_PROGRAM_VERIFICATION"

tools/cmake/Utils.cmake

-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ function(executorch_print_configuration_summary)
3232
message(STATUS " EXECUTORCH_ENABLE_PROGRAM_VERIFICATION : "
3333
"${EXECUTORCH_ENABLE_PROGRAM_VERIFICATION}"
3434
)
35-
message(
36-
STATUS " EXECUTORCH_LOG_LEVEL : ${EXECUTORCH_LOG_LEVEL}"
37-
)
3835
message(STATUS " EXECUTORCH_BUILD_ANDROID_JNI : "
3936
"${EXECUTORCH_BUILD_ANDROID_JNI}"
4037
)

tools/cmake/preset/default.cmake

+18-1
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,28 @@ define_overridable_option(
3939
"PAL implementation file path"
4040
STRING "${PROJECT_SOURCE_DIR}/runtime/platform/default/${EXECUTORCH_PAL_DEFAULT}.cpp"
4141
)
42-
42+
define_overridable_option(
43+
EXECUTORCH_LOG_LEVEL
44+
"Build with the given ET_MIN_LOG_LEVEL value"
45+
STRING "Info"
46+
)
4347

4448
# MARK: - Validations
4549
# At this point all the options should be configured with their final value.
4650

4751
if(NOT EXISTS ${EXECUTORCH_PAL_DEFAULT_FILE_PATH})
4852
message(FATAL_ERROR "PAL default implementation (EXECUTORCH_PAL_DEFAULT=${EXECUTORCH_PAL_DEFAULT}) file not found: ${EXECUTORCH_PAL_DEFAULT_FILE_PATH}. Choices: posix, minimal")
4953
endif()
54+
55+
string(TOLOWER "${EXECUTORCH_LOG_LEVEL}" _executorch_log_level_lower)
56+
if(_executorch_log_level_lower STREQUAL "debug")
57+
set(ET_MIN_LOG_LEVEL Debug)
58+
elseif(_executorch_log_level_lower STREQUAL "info")
59+
set(ET_MIN_LOG_LEVEL Info)
60+
elseif(_executorch_log_level_lower STREQUAL "error")
61+
set(ET_MIN_LOG_LEVEL Error)
62+
elseif(_executorch_log_level_lower STREQUAL "fatal")
63+
set(ET_MIN_LOG_LEVEL Fatal)
64+
else()
65+
message(FATAL_ERROR "Unknown EXECUTORCH_LOG_LEVEL '${EXECUTORCH_LOG_LEVEL}'. Choices: Debug, Info, Error, Fatal")
66+
endif()

0 commit comments

Comments
 (0)