blob: a0733a7b1fa175fcf680421bb6311d1c1f80aad5 [file]
Stub out LOG(), PLOG(), CHECK() and CHECK_OP() streams in logging.h
A no-op FakeLog replaces android::base::LogMessage, so the libbase and
ART code that logs through logging.h needs no android-base/logging.cpp,
which BUILD.gn does not build. logging.cpp uses BSD's getprogname(),
which the NDK has only from API level 21 (https://bit.ly/2nX0nBs).
Chromium commit 1ac11f3 in libunwindstack.git; 72ad10f and 11659d4
did the same in file.cpp before.
diff --git a/src/include/android-base/logging.h b/src/include/android-base/logging.h
index 7b6e599..1a2906e 100644
--- a/src/include/android-base/logging.h
+++ b/src/include/android-base/logging.h
@@ -229,7 +229,13 @@ struct LogAbortAfterFullExpr {
// FATAL it also causes an abort. For example:
//
// LOG(FATAL) << "We didn't expect to reach here";
-#define LOG(severity) LOGGING_PREAMBLE(severity) && LOG_STREAM(severity)
+class FakeLog {
+ public:
+ template<typename T>
+ FakeLog operator<<(const T&) { return *this; }
+ operator bool() { return false; }
+};
+#define LOG(severity) false && ::android::base::FakeLog()
// Conditionally logs a message based on a specified severity level and a boolean condition.
// Logs to logcat on Android, or to stderr on host. See also LOG(severity) above.
@@ -260,11 +266,7 @@ struct LogAbortAfterFullExpr {
// A variant of LOG that also logs the current errno value. To be used when
// library calls fail.
-#define PLOG(severity) \
- LOGGING_PREAMBLE(severity) && \
- ::android::base::LogMessage(__FILE__, __LINE__, SEVERITY_LAMBDA(severity), \
- _LOG_TAG_INTERNAL, errno) \
- .stream()
+#define PLOG(severity) false && ::android::base::FakeLog()
// Marker that code is yet to be implemented.
#define UNIMPLEMENTED(level) \
@@ -278,9 +280,7 @@ struct LogAbortAfterFullExpr {
// "Check failed: false == true".
#define CHECK(x) \
LIKELY((x)) || ABORT_AFTER_LOG_FATAL_EXPR(false) || \
- ::android::base::LogMessage(__FILE__, __LINE__, ::android::base::FATAL, _LOG_TAG_INTERNAL, \
- -1) \
- .stream() \
+ ::android::base::FakeLog() \
<< "Check failed: " #x << " "
// clang-format off
@@ -290,8 +290,7 @@ struct LogAbortAfterFullExpr {
UNLIKELY(!(_values.lhs.v OP _values.rhs.v)); \
/* empty */) \
ABORT_AFTER_LOG_FATAL \
- ::android::base::LogMessage(__FILE__, __LINE__, ::android::base::FATAL, _LOG_TAG_INTERNAL, -1) \
- .stream() \
+ ::android::base::FakeLog() \
<< "Check failed: " << #LHS << " " << #OP << " " << #RHS << " (" #LHS "=" \
<< ::android::base::LogNullGuard<decltype(_values.lhs.v)>::Guard(_values.lhs.v) \
<< ", " #RHS "=" \