Actually abort update_engine for CHECK failure
__android_log_write won't abort the program by itself. Since we are
not using libchrome's aborter, call __android_log_assert explicitly
on FATAL errors.
Bug: 182310095
Test: check update_engine aborts for CHECK failure
Change-Id: I41805f2b8294bba696e713100088dd720dd66356
diff --git a/aosp/logging_android.cc b/aosp/logging_android.cc
index 0219075..5ccf7bc 100644
--- a/aosp/logging_android.cc
+++ b/aosp/logging_android.cc
@@ -240,9 +240,16 @@
std::string_view sv = str_newline;
ignore_result(android::base::ConsumeSuffix(&sv, "\n"));
std::string str(sv.data(), sv.size());
- // This will eventually be redirected to CombinedLogger.
- // Use nullptr as tag so that liblog infers log tag from getprogname().
- __android_log_write(priority, nullptr /* tag */, str.c_str());
+
+ if (priority == ANDROID_LOG_FATAL) {
+ // Abort the program for priority FATAL. __android_log_assert will log the
+ // message to stderr and CombinedLogger.
+ __android_log_assert(nullptr, nullptr, "%s", str.c_str());
+ } else {
+ // This will eventually be redirected to CombinedLogger.
+ // Use nullptr as tag so that liblog infers log tag from getprogname().
+ __android_log_write(priority, nullptr /* tag */, str.c_str());
+ }
return true;
}