From 92e379663aef11c66af706932188bb69f00d640b Mon Sep 17 00:00:00 2001 From: Karl Wiberg Date: Tue, 22 Sep 2020 13:22:20 +0200 Subject: [PATCH] RTC_LOG: Fix bug introduced in a recent CL https://webrtc-review.googlesource.com/c/src/+/184922 removed the check for whether we should actually emit a given log message or not from the main logging function, and attempted to put it around each call site instead, so that we could check first and avoid computing log arguments if the check says no. However, it missed these two places. Bug: webrtc:11968 Change-Id: I1a0d68888d1a2c9814bc02fe9db49d7084bad8fd Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/185004 Reviewed-by: Mirko Bonadei Reviewed-by: Tommi Commit-Queue: Karl Wiberg Cr-Commit-Position: refs/heads/master@{#32162} --- rtc_base/logging.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/rtc_base/logging.h b/rtc_base/logging.h index 4a0e090f94..d2607c28b7 100644 --- a/rtc_base/logging.h +++ b/rtc_base/logging.h @@ -638,11 +638,12 @@ inline bool LogCheckLevel(LoggingSeverity sev) { return (LogMessage::GetMinLogSeverity() <= sev); } -#define RTC_LOG_E(sev, ctx, err) \ - RTC_LOG_ENABLED() && ::rtc::webrtc_logging_impl::LogCall() & \ - ::rtc::webrtc_logging_impl::LogStreamer<>() \ - << ::rtc::webrtc_logging_impl::LogMetadataErr { \ - {__FILE__, __LINE__, ::rtc::sev}, ::rtc::ERRCTX_##ctx, (err) \ +#define RTC_LOG_E(sev, ctx, err) \ + !rtc::LogMessage::IsNoop<::rtc::sev>() && \ + ::rtc::webrtc_logging_impl::LogCall() & \ + ::rtc::webrtc_logging_impl::LogStreamer<>() \ + << ::rtc::webrtc_logging_impl::LogMetadataErr { \ + {__FILE__, __LINE__, ::rtc::sev}, ::rtc::ERRCTX_##ctx, (err) \ } #define RTC_LOG_T(sev) RTC_LOG(sev) << this << ": " @@ -675,11 +676,12 @@ inline const char* AdaptString(const std::string& str) { } } // namespace webrtc_logging_impl -#define RTC_LOG_TAG(sev, tag) \ - RTC_LOG_ENABLED() && ::rtc::webrtc_logging_impl::LogCall() & \ - ::rtc::webrtc_logging_impl::LogStreamer<>() \ - << ::rtc::webrtc_logging_impl::LogMetadataTag { \ - sev, ::rtc::webrtc_logging_impl::AdaptString(tag) \ +#define RTC_LOG_TAG(sev, tag) \ + !rtc::LogMessage::IsNoop(sev) && \ + ::rtc::webrtc_logging_impl::LogCall() & \ + ::rtc::webrtc_logging_impl::LogStreamer<>() \ + << ::rtc::webrtc_logging_impl::LogMetadataTag { \ + sev, ::rtc::webrtc_logging_impl::AdaptString(tag) \ } #else