Make __android_log_assert behave more like libc asserts.
If we don't output to stderr too, not only is it annoying to shell users (who
won't see anything), it prevents us from writing better gtests that actually
make assertions about the assert message.
Bug: http://b/23675822
Test: libutils tests still pass
Change-Id: I62b3144c385cba4dde485f0b0f9b42aeaef51e9a
diff --git a/liblog/logger_write.c b/liblog/logger_write.c
index 1a2d506..4324125 100644
--- a/liblog/logger_write.c
+++ b/liblog/logger_write.c
@@ -514,6 +514,14 @@
strcpy(buf, "Unspecified assertion failed");
}
+ // Log assertion failures to stderr for the benefit of "adb shell" users
+ // and gtests (http://b/23675822).
+ struct iovec iov[2] = {
+ { buf, strlen(buf) },
+ { (char*) "\n", 1 },
+ };
+ TEMP_FAILURE_RETRY(writev(2, iov, 2));
+
__android_log_write(ANDROID_LOG_FATAL, tag, buf);
abort(); /* abort so we have a chance to debug the situation */
/* NOTREACHED */