Internal cleanup

PiperOrigin-RevId: 1013155115
diff --git a/absl/base/config.h b/absl/base/config.h
index 4761f25..53ff2cb 100644
--- a/absl/base/config.h
+++ b/absl/base/config.h
@@ -312,6 +312,21 @@
 #define ABSL_HAVE_EXCEPTIONS 1
 #endif
 
+// ABSL_INTERNAL_HAVE_STD_OSTREAM
+//
+// Checks whether the standard library provides `std::ostream`. libc++ can be
+// configured without localization support, in which case `<ostream>` declares
+// nothing and Abseil omits its `operator<<` overloads.
+#ifdef ABSL_INTERNAL_HAVE_STD_OSTREAM
+#error ABSL_INTERNAL_HAVE_STD_OSTREAM cannot be directly set.
+#elif defined(_LIBCPP_HAS_NO_LOCALIZATION) || \
+    (defined(_LIBCPP_HAS_LOCALIZATION) && !_LIBCPP_HAS_LOCALIZATION)
+// libc++ built without localization support (LLVM < 20 and LLVM >= 20
+// spellings respectively) provides no `std::ostream`.
+#else
+#define ABSL_INTERNAL_HAVE_STD_OSTREAM 1
+#endif
+
 // -----------------------------------------------------------------------------
 // Platform Feature Checks
 // -----------------------------------------------------------------------------
diff --git a/absl/base/internal/raw_logging.cc b/absl/base/internal/raw_logging.cc
index f705a38..7e0ef15 100644
--- a/absl/base/internal/raw_logging.cc
+++ b/absl/base/internal/raw_logging.cc
@@ -107,7 +107,6 @@
   *buf += n;
   return result;
 }
-#endif  // ABSL_LOW_LEVEL_WRITE_SUPPORTED
 
 constexpr int kLogBufSize = 3000;
 
@@ -136,6 +135,17 @@
   DoRawLog(buf, buf_size, "[%s : %d] RAW: ", file, line);
   return true;
 }
+#else   // !ABSL_LOW_LEVEL_WRITE_SUPPORTED
+// No message can be emitted on this platform, so nothing is formatted.  The
+// buffer only has to hold the NUL terminator the abort hook contract requires,
+// and a prefix hook sees a size of 1.
+constexpr int kLogBufSize = 1;
+
+bool DefaultLogFilterAndPrefix(absl::LogSeverity, const char*, int, char**,
+                               int*) {
+  return true;
+}
+#endif  // ABSL_LOW_LEVEL_WRITE_SUPPORTED
 
 ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES
 absl::base_internal::AtomicHook<LogFilterAndPrefixHook>
@@ -149,6 +159,9 @@
 void RawLogVA(absl::LogSeverity severity, const char* file, int line,
               const char* format, va_list ap) {
   char buffer[kLogBufSize];
+  // The prefix hook may legitimately write nothing; the buffer handed to the
+  // abort hook must be NUL-terminated regardless.
+  buffer[0] = '\0';
   char* buf = buffer;
   int size = sizeof(buffer);
 #ifdef ABSL_LOW_LEVEL_WRITE_SUPPORTED
diff --git a/absl/base/log_severity.cc b/absl/base/log_severity.cc
index 8e7bbbc..303a132 100644
--- a/absl/base/log_severity.cc
+++ b/absl/base/log_severity.cc
@@ -14,11 +14,13 @@
 
 #include "absl/base/log_severity.h"
 
-#include <ostream>
-
 #include "absl/base/attributes.h"
 #include "absl/base/config.h"
 
+#ifdef ABSL_INTERNAL_HAVE_STD_OSTREAM
+
+#include <ostream>
+
 namespace absl {
 ABSL_NAMESPACE_BEGIN
 
@@ -52,5 +54,8 @@
   }
   return os;
 }
+
 ABSL_NAMESPACE_END
 }  // namespace absl
+
+#endif  // ABSL_INTERNAL_HAVE_STD_OSTREAM
diff --git a/absl/base/log_severity.h b/absl/base/log_severity.h
index de9702a..b20fd11 100644
--- a/absl/base/log_severity.h
+++ b/absl/base/log_severity.h
@@ -16,7 +16,7 @@
 #define ABSL_BASE_LOG_SEVERITY_H_
 
 #include <array>
-#include <ostream>
+#include <iosfwd>
 
 #include "absl/base/attributes.h"
 #include "absl/base/config.h"
@@ -126,7 +126,9 @@
 //
 // The exact representation of a streamed `absl::LogSeverity` is deliberately
 // unspecified; do not rely on it.
+#ifdef ABSL_INTERNAL_HAVE_STD_OSTREAM
 std::ostream& operator<<(std::ostream& os, absl::LogSeverity s);
+#endif  // ABSL_INTERNAL_HAVE_STD_OSTREAM
 
 // Enums representing a lower bound for LogSeverity. APIs that only operate on
 // messages of at least a certain level (for example, `SetMinLogLevel()`) use
@@ -141,7 +143,9 @@
   kInfinity = 1000,
 };
 
+#ifdef ABSL_INTERNAL_HAVE_STD_OSTREAM
 std::ostream& operator<<(std::ostream& os, absl::LogSeverityAtLeast s);
+#endif  // ABSL_INTERNAL_HAVE_STD_OSTREAM
 
 // Enums representing an upper bound for LogSeverity. APIs that only operate on
 // messages of at most a certain level (for example, buffer all messages at or
@@ -156,7 +160,9 @@
   kFatal = static_cast<int>(absl::LogSeverity::kFatal),
 };
 
+#ifdef ABSL_INTERNAL_HAVE_STD_OSTREAM
 std::ostream& operator<<(std::ostream& os, absl::LogSeverityAtMost s);
+#endif  // ABSL_INTERNAL_HAVE_STD_OSTREAM
 
 #define COMPOP(op1, op2, T)                                         \
   constexpr bool operator op1(absl::T lhs, absl::LogSeverity rhs) { \