cros: Build time VLOG
This CL introduce build time vlog that uses a ENABLED_VLOG_LEVEL
to back VLOG_IS_ON instead of calculating from --vmodule patterns.
Essentially, VLOG -> VLOG_IS_ON becomes cheap by just comparing
with a number instead of looping through all vmodule patterns and
doing regexp match. Note this implies that --vmodule=xxx and --v=x
would be complete ignored when build time vlog is enabled.
The macro works at build time, compiler could optimize out VLOGs
that will not be executed and reduce about 800k chrome binary size.
A new gn arg `enable_runtime_vlog` is added to control whether to
use runtime vlog or build time vlog. `enable_runtime_vlog` is true
everywhere except for ash-chrome, where it is set to false to use
build time vlogs.
When runtime vlog is used, vlogs could be controlled by --vmodule=xxx
and --v=x. When build time vlog is used, VLOGs are processed at build
time. And command line switch --vmodule and --v would have no effect
at runtime for such build.
Bug: 489441
Change-Id: Ia18891ef5a7f1e183137fb4fcf19918d5f64ea01
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3334864
Reviewed-by: Lei Zhang <[email protected]>
Reviewed-by: Olivier Li <[email protected]>
Commit-Queue: Xiyuan Xia <[email protected]>
Reviewed-by: Achuith Bhandarkar <[email protected]>
Reviewed-by: Nico Weber <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1000043}
diff --git a/components/webrtc_logging/logging_unittest.cc b/components/webrtc_logging/logging_unittest.cc
index 77847c2..2085eae9 100644
--- a/components/webrtc_logging/logging_unittest.cc
+++ b/components/webrtc_logging/logging_unittest.cc
@@ -68,7 +68,14 @@
if (!logging::InitLogging(settings)) {
return false;
}
+
+#if BUILDFLAG(USE_RUNTIME_VLOG)
EXPECT_TRUE(VLOG_IS_ON(verbosity_level));
+#else
+ // VLOGs default to off when not using runtime vlog.
+ EXPECT_FALSE(VLOG_IS_ON(verbosity_level));
+#endif // BUILDFLAG(USE_RUNTIME_VLOG)
+
EXPECT_FALSE(VLOG_IS_ON(verbosity_level + 1));
return true;
}
@@ -147,9 +154,12 @@
// Make sure string contains the expected values.
EXPECT_TRUE(ContainsString(contents_of_file, AsString(rtc::LS_ERROR)));
EXPECT_TRUE(ContainsString(contents_of_file, AsString(rtc::LS_WARNING)));
+
+#if BUILDFLAG(USE_RUNTIME_VLOG)
EXPECT_TRUE(ContainsString(contents_of_file, AsString(rtc::LS_INFO)));
// RTC_LOG_E
EXPECT_TRUE(ContainsString(contents_of_file, strerror(kFakeError)));
EXPECT_TRUE(ContainsString(contents_of_file, AsString(rtc::LS_VERBOSE)));
EXPECT_TRUE(ContainsString(contents_of_file, AsString(rtc::LS_SENSITIVE)));
+#endif // BUILDFLAG(USE_RUNTIME_VLOG)
}