Skip to content

Commit 8a77107

Browse files
lucylqfacebook-github-bot
authored andcommitted
et_log (#2303)
Summary: Enable logging if true / by default Disable logging if false Reviewed By: mergennachin, kirklandsign Differential Revision: D54652427
1 parent f6d0d49 commit 8a77107

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

runtime/platform/targets.bzl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ def _select_pal(dict_):
1010
fail("Missing key for executorch.pal_default value '{}' in dict '{}'".format(pal_default, dict_))
1111
return dict_[pal_default]
1212

13+
def logging_enabled():
14+
return native.read_config("executorch", "enable_et_log", "true") == "true"
15+
16+
def get_logging_flags():
17+
if logging_enabled():
18+
# On by default.
19+
return []
20+
else:
21+
return ["-DET_LOG_ENABLED=0"]
22+
1323
def profiling_enabled():
1424
return native.read_config("executorch", "prof_enabled", "false") == "true"
1525

@@ -57,9 +67,6 @@ def define_common_targets():
5767
force_static = True,
5868
)
5969

60-
# Enable or disable ET_LOGs
61-
enable_et_log = native.read_config("executorch", "enable_et_log", None)
62-
6370
# Interfaces for executorch users
6471
runtime.cxx_library(
6572
name = "platform",
@@ -77,7 +84,7 @@ def define_common_targets():
7784
"profiler.cpp",
7885
"runtime.cpp",
7986
],
80-
exported_preprocessor_flags = get_profiling_flags() + (["-DET_LOG_ENABLED=0"] if enable_et_log else []),
87+
exported_preprocessor_flags = get_profiling_flags() + get_logging_flags(),
8188
exported_deps = [
8289
"//executorch/runtime/platform:pal_interface",
8390
":compiler",

0 commit comments

Comments
 (0)