Base: Check severity in destructor
Bug: 31338270
Test: m
Test: mmma system/core/base && $ANDROID_HOST_OUT/nativetest64/libbase_test/libbase_test64
Change-Id: Ic077822bcfd591bd11f4fa9d4b6e440b461c70c1
diff --git a/logging.cpp b/logging.cpp
index 77a0a43..2ca2246 100644
--- a/logging.cpp
+++ b/logging.cpp
@@ -390,6 +390,11 @@
}
LogMessage::~LogMessage() {
+ // Check severity again. This is duplicate work wrt/ LOG macros, but not LOG_STREAM.
+ if (!WOULD_LOG_SEVERITY(data_->GetSeverity())) {
+ return;
+ }
+
// Finish constructing the message.
if (data_->GetError() != -1) {
data_->GetBuffer() << ": " << strerror(data_->GetError());