cros: Revert back to runtime vlog with a tweak
Runtime vlog is needed by tests and devs that would like be able
to turn VLOGs on during test or development. This CL reverts back
to runtime VLOG for ash-chrome with a tweak that VLOGs could be
also turned on at compile time using the ENABLED_VLOG_LEVEL macros.
This allows VLOGs be collected from fields without using --vmodule,
which adds cpu overhead to every VLOG.
Bug: 1495473, 489441
Change-Id: I49a1d26d2021fefdaa8283afede9b93cb3814e05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4998093
Reviewed-by: Lei Zhang <[email protected]>
Reviewed-by: Elad Alon <[email protected]>
Reviewed-by: Jonathan Ross <[email protected]>
Reviewed-by: Miguel Casas-Sanchez <[email protected]>
Commit-Queue: Xiyuan Xia <[email protected]>
Reviewed-by: Dirk Pranke <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1219142}
diff --git a/base/logging.h b/base/logging.h
index 0955b9c..7e75485b 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -17,7 +17,6 @@
#include "base/compiler_specific.h"
#include "base/dcheck_is_on.h"
#include "base/functional/callback_forward.h"
-#include "base/logging_buildflags.h"
#include "base/scoped_clear_last_error.h"
#include "base/strings/string_piece_forward.h"
#include "base/strings/utf_ostream_operators.h"
@@ -92,16 +91,7 @@
//
// These always log at the INFO log level (when they log at all).
//
-// There is a build flag USE_RUNTIME_VLOG that controls whether verbose
-// logging is processed at runtime or at build time.
-//
-// When USE_RUNTIME_VLOG is not set, the verbose logging is processed at
-// build time. VLOG(n) is only included and compiled when `n` is less than or
-// equal to the verbose level defined by ENABLED_VLOG_LEVEL macro. Command line
-// switch --v and --vmodule are ignored in this mode.
-//
-// When USE_RUNTIME_VLOG is set, the verbose logging is controlled at
-// runtime and can be turned on module-by-module. For instance,
+// The verbose logging can also be turned on module-by-module. For instance,
// --vmodule=profile=2,icon_loader=1,browser_*=3,*/chromeos/*=4 --v=0
// will cause:
// a. VLOG(2) and lower messages to be printed from profile.{h,cc}
@@ -443,54 +433,22 @@
#define LOG_IS_ON(severity) \
(::logging::ShouldCreateLogMessage(::logging::LOGGING_##severity))
-#if !BUILDFLAG(USE_RUNTIME_VLOG)
-
-// When USE_RUNTIME_VLOG is not set, --vmodule is completely ignored and
-// ENABLED_VLOG_LEVEL macro is used to determine the enabled VLOG levels
-// at build time.
-//
-// Files that need VLOG would need to redefine ENABLED_VLOG_LEVEL to a desired
-// VLOG level number,
-// e.g.
-// To enable VLOG(1) output,
-//
-// For a source cc file:
-//
-// #undef ENABLED_VLOG_LEVEL
-// #define ENABLED_VLOG_LEVEL 1
-//
-// For all cc files in a build target of a BUILD.gn:
-//
-// source_set("build_target") {
-// ...
-//
-// defines = ["ENABLED_VLOG_LEVEL=1"]
-// }
-
-// Returns a vlog level that suppresses all vlogs. Using this function so that
-// compiler cannot calculate VLOG_IS_ON() and generate unreached code
-// warnings.
-BASE_EXPORT int GetDisableAllVLogLevel();
-
-// Define the default ENABLED_VLOG_LEVEL if it is not defined. This is to
-// allow ENABLED_VLOG_LEVEL to be overridden from defines in cc flags.
+// Define a default ENABLED_VLOG_LEVEL if it is not defined. The macros allows
+// code to enable vlog level at build time without the need of --vmodule
+// switch at runtime. This is intended for VLOGs that needed from production
+// code without the cpu overhead to match vmodule patterns on every VLOG
+// instance.
#if !defined(ENABLED_VLOG_LEVEL)
-#define ENABLED_VLOG_LEVEL (logging::GetDisableAllVLogLevel())
+#define ENABLED_VLOG_LEVEL -1
#endif // !defined(ENABLED_VLOG_LEVEL)
-#define VLOG_IS_ON(verboselevel) ((verboselevel) <= (ENABLED_VLOG_LEVEL))
-
-#else // !BUILDFLAG(USE_RUNTIME_VLOG)
-
// We don't do any caching tricks with VLOG_IS_ON() like the
// google-glog version since it increases binary size. This means
// that using the v-logging functions in conjunction with --vmodule
// may be slow.
-
-#define VLOG_IS_ON(verboselevel) \
- ((verboselevel) <= ::logging::GetVlogLevel(__FILE__))
-
-#endif // !BUILDFLAG(USE_RUNTIME_VLOG)
+#define VLOG_IS_ON(verboselevel) \
+ ((verboselevel) <= (ENABLED_VLOG_LEVEL) || \
+ (verboselevel) <= ::logging::GetVlogLevel(__FILE__))
// Helper macro which avoids evaluating the arguments to a stream if
// the condition doesn't hold. Condition is evaluated once and only once.