Skip to content

Commit ef3c1d2

Browse files
JakeStevensfacebook-github-bot
authored andcommitted
Add executorch-et-log-disabled constraint honored by log.bzl (#20187)
Summary: Adds support to disable logging using BUCK constraint Reviewed By: rascani Differential Revision: D108152661
1 parent c26c649 commit ef3c1d2

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

runtime/platform/log.bzl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
def et_logging_enabled():
22
return native.read_config("executorch", "enable_et_log", "true") == "true"
33

4+
def is_oss():
5+
return native.read_config("executorch", "is_oss", "0") == "1"
6+
47
def et_log_level():
58
raw_level = native.read_config("executorch", "log_level", "Info").lower()
69
if raw_level == "debug":
@@ -16,7 +19,14 @@ def et_log_level():
1619

1720
def get_et_logging_flags():
1821
if et_logging_enabled():
19-
# On by default.
20-
return ["-DET_MIN_LOG_LEVEL=" + et_log_level()]
22+
if is_oss():
23+
return ["-DET_MIN_LOG_LEVEL=" + et_log_level()]
24+
25+
# On by default; allow opt-out via constraint (the executorch.enable_et_log
26+
# buckconfig above remains an independent way to disable logging).
27+
return select({
28+
"DEFAULT": ["-DET_MIN_LOG_LEVEL=" + et_log_level()],
29+
"fbsource//xplat/executorch/tools/buck/constraints:executorch-et-log-disabled": ["-DET_LOG_ENABLED=0"],
30+
})
2131
else:
2232
return ["-DET_LOG_ENABLED=0"]

tools/buck/constraints/BUCK

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,22 @@ fb_native.constraint_value(
9999
constraint_setting = ":executorch-builtin-function-name",
100100
visibility = ["PUBLIC"],
101101
)
102+
103+
fb_native.config_setting(
104+
name = "executorch-et-log-disabled",
105+
constraint_values = [
106+
":et-log-disabled",
107+
],
108+
visibility = ["PUBLIC"],
109+
)
110+
111+
fb_native.constraint_setting(
112+
name = "executorch-et-log",
113+
visibility = ["PUBLIC"],
114+
)
115+
116+
fb_native.constraint_value(
117+
name = "et-log-disabled",
118+
constraint_setting = ":executorch-et-log",
119+
visibility = ["PUBLIC"],
120+
)

0 commit comments

Comments
 (0)