Skip to content

Commit 5be0e3b

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). Reviewed By: digantdesai Differential Revision: D55147165 Pulled By: GregoryComer
1 parent a41ac1c commit 5be0e3b

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Copyright (c) Meta Platforms, Inc. and affiliates.
22
# All rights reserved.
33
#
4-
# Copyright 2024 Arm Limited and/or its affiliates.
5-
#
64
# This source code is licensed under the BSD-style license found in the
75
# LICENSE file in the root directory of this source tree.
86

@@ -34,6 +32,8 @@ function(executorch_print_configuration_summary)
3432
message(STATUS " FLATC_EXECUTABLE : ${FLATC_EXECUTABLE}")
3533
message(
3634
STATUS " EXECUTORCH_ENABLE_LOGGING : ${EXECUTORCH_ENABLE_LOGGING}")
35+
message(
36+
STATUS " EXECUTORCH_LOG_LEVEL : ${EXECUTORCH_LOG_LEVEL}")
3737
message(STATUS " EXECUTORCH_ENABLE_PROGRAM_VERIFICATION : "
3838
"${EXECUTORCH_ENABLE_PROGRAM_VERIFICATION}")
3939
message(
@@ -46,6 +46,8 @@ function(executorch_print_configuration_summary)
4646
)
4747
message(
4848
STATUS " REGISTER_EXAMPLE_CUSTOM_OPS : ${REGISTER_EXAMPLE_CUSTOM_OPS}")
49+
message(STATUS " EXECUTORCH_BUILD_EXTENSION_AOT_UTIL : "
50+
"${EXECUTORCH_BUILD_EXTENSION_AOT_UTIL}")
4951
message(STATUS " EXECUTORCH_BUILD_EXTENSION_DATA_LOADER : "
5052
"${EXECUTORCH_BUILD_EXTENSION_DATA_LOADER}")
5153
message(STATUS " EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL : "

0 commit comments

Comments
 (0)