Revert "Consolidate loggability checks and replace streams."

This reverts commit 4092cd6db459ab8152588143b7b76e0946d2c433.

Reason for revert: Some g3 things depend on log macro implementation details.

Original change's description:
> Consolidate loggability checks and replace streams.
> 
> Currently we check if a message should be printed at the call site using LogMessage::Loggable, in the LogMessage itself using LogMessage::IsNoop and in LogMessage::OutputToDebug using log_to_stderr_.
> 
> This change unifies the first two of these into a early return in Log().
> 
> Bug: webrtc:8982
> Change-Id: Ia4e3e12b34716d76c05807e44db1ed4a62dffb87
> Reviewed-on: https://webrtc-review.googlesource.com/97440
> Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org>
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#24547}

TBR=kwiberg@webrtc.org,jonasolsson@webrtc.org

Change-Id: I06f0a5b50c96c08a5e7be4d8d2bcb22d50c0179f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:8982
Reviewed-on: https://webrtc-review.googlesource.com/97720
Reviewed-by: Jonas Olsson <jonasolsson@webrtc.org>
Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24553}
diff --git a/rtc_base/logging_unittest.cc b/rtc_base/logging_unittest.cc
index 263e992..af51212 100644
--- a/rtc_base/logging_unittest.cc
+++ b/rtc_base/logging_unittest.cc
@@ -150,6 +150,7 @@
       : LogMessage(file, line, sev, err_ctx, err) {}
 
   const std::string& get_extra() const { return extra_; }
+  bool is_noop() const { return is_noop_; }
 #if defined(WEBRTC_ANDROID)
   const char* get_tag() const { return tag_; }
 #endif
@@ -162,7 +163,10 @@
     RTC_DCHECK(!is_finished_);
     is_finished_ = true;
     FinishPrintStream();
-    return print_stream_.Release();
+    std::string ret = print_stream_.str();
+    // Just to make an error even more clear if the stream gets used after this.
+    print_stream_.clear();
+    return ret;
   }
 
  private:
@@ -299,6 +303,7 @@
 TEST(LogTest, CheckExtraErrorField) {
   LogMessageForTesting log_msg("some/path/myfile.cc", 100, LS_WARNING,
                                ERRCTX_ERRNO, 0xD);
+  ASSERT_FALSE(log_msg.is_noop());
   log_msg.stream() << "This gets added at dtor time";
 
   const std::string& extra = log_msg.get_extra();
@@ -309,6 +314,7 @@
 
 TEST(LogTest, CheckFilePathParsed) {
   LogMessageForTesting log_msg("some/path/myfile.cc", 100, LS_INFO);
+  ASSERT_FALSE(log_msg.is_noop());
   log_msg.stream() << "<- Does this look right?";
 
   const std::string stream = log_msg.GetPrintStream();
@@ -334,6 +340,21 @@
 }
 #endif
 
+TEST(LogTest, CheckNoopLogEntry) {
+  if (LogMessage::GetLogToDebug() <= LS_SENSITIVE) {
+    printf("CheckNoopLogEntry: skipping. Global severity is being overridden.");
+    return;
+  }
+
+  // Logging at LS_SENSITIVE severity, is by default turned off, so this should
+  // be treated as a noop message.
+  LogMessageForTesting log_msg("some/path/myfile.cc", 100, LS_SENSITIVE);
+  log_msg.stream() << "Should be logged to nowhere.";
+  EXPECT_TRUE(log_msg.is_noop());
+  const std::string stream = log_msg.GetPrintStream();
+  EXPECT_TRUE(stream.empty());
+}
+
 // Test the time required to write 1000 80-character logs to a string.
 TEST(LogTest, Perf) {
   std::string str;
@@ -342,7 +363,10 @@
 
   const std::string message(80, 'X');
   {
+    // Just to be sure that we're not measuring the performance of logging
+    // noop log messages.
     LogMessageForTesting sanity_check_msg(__FILE__, __LINE__, LS_SENSITIVE);
+    ASSERT_FALSE(sanity_check_msg.is_noop());
   }
 
   // We now know how many bytes the logging framework will tag onto every msg.