Disable debug log spam when embedded in a third party project
Bug: crbug.com/904249
Change-Id: I41beddffca22e8dc7d8349975208835778235476
diff --git a/gn/BUILD.gn b/gn/BUILD.gn
index e4e8e70..75137f9 100644
--- a/gn/BUILD.gn
+++ b/gn/BUILD.gn
@@ -117,6 +117,11 @@
}
}
+ # Disable debug log spam if we're embedded in a third-party project.
+ if (!perfetto_build_with_embedder) {
+ defines += [ "PERFETTO_ENABLE_DLOG" ]
+ }
+
include_dirs = [
"..",
"../include",
diff --git a/include/perfetto/base/logging.h b/include/perfetto/base/logging.h
index ab3e027..8da3e0a 100644
--- a/include/perfetto/base/logging.h
+++ b/include/perfetto/base/logging.h
@@ -28,6 +28,12 @@
#define PERFETTO_DCHECK_IS_ON() 1
#endif
+#if defined(PERFETTO_ENABLE_DLOG)
+#define PERFETTO_DLOG_IS_ON() PERFETTO_DCHECK_IS_ON()
+#else
+#define PERFETTO_DLOG_IS_ON() 0
+#endif
+
#include "perfetto/base/build_config.h"
#include "perfetto/base/utils.h"
@@ -114,13 +120,22 @@
#define PERFETTO_PLOG(x, ...) \
PERFETTO_ELOG(x " (errno: %d, %s)", ##__VA_ARGS__, errno, strerror(errno))
-#if PERFETTO_DCHECK_IS_ON()
+#if PERFETTO_DLOG_IS_ON()
#define PERFETTO_DLOG(fmt, ...) PERFETTO_XLOG(kLogDebug, fmt, ##__VA_ARGS__)
#define PERFETTO_DPLOG(x, ...) \
PERFETTO_DLOG(x " (errno: %d, %s)", ##__VA_ARGS__, errno, strerror(errno))
+#else
+
+#define PERFETTO_DLOG(...) ::perfetto::base::ignore_result(__VA_ARGS__)
+#define PERFETTO_DPLOG(...) ::perfetto::base::ignore_result(__VA_ARGS__)
+
+#endif // PERFETTO_DLOG_IS_ON()
+
+#if PERFETTO_DCHECK_IS_ON()
+
#define PERFETTO_DCHECK(x) \
do { \
if (PERFETTO_UNLIKELY(!(x))) { \
@@ -137,8 +152,6 @@
#else
-#define PERFETTO_DLOG(...) ::perfetto::base::ignore_result(__VA_ARGS__)
-#define PERFETTO_DPLOG(...) ::perfetto::base::ignore_result(__VA_ARGS__)
#define PERFETTO_DCHECK(x) ::perfetto::base::ignore_result(x)
#define PERFETTO_DFATAL(...) ::perfetto::base::ignore_result(__VA_ARGS__)