Convert Log class to llvm streams

Summary:
This converts LLDB's logging to use llvm streams instead of
lldb_private::Stream and friends. The changes are mostly
straight-forward and amount to s/lldb_private::Stream/llvm::raw_ostream.

The part worth calling out is the rewrite of the StreamCallback class.
Previously this class contained a per-thread buffer of data written. I
assume this had something to do with it trying to make sure each log
line is delivered as a single event, instead of multiple (possibly
interleaved) events. However, this is no longer relevant as the Log
class already writes things to a temporary buffer and then delivers the
message as a single "write", so I have just removed the code in
question.

Reviewers: zturner, clayborg

Subscribers: emaste, lldb-commits, mgorny

Differential Revision: https://reviews.llvm.org/D29615

llvm-svn: 294736
diff --git a/lldb/source/Core/Log.cpp b/lldb/source/Core/Log.cpp
index a2ff2f2..14b2378 100644
--- a/lldb/source/Core/Log.cpp
+++ b/lldb/source/Core/Log.cpp
@@ -38,7 +38,7 @@
 
 Log::Log() : m_stream_sp(), m_options(0), m_mask_bits(0) {}
 
-Log::Log(const StreamSP &stream_sp)
+Log::Log(const std::shared_ptr<llvm::raw_ostream> &stream_sp)
     : m_stream_sp(stream_sp), m_options(0), m_mask_bits(0) {}
 
 Log::~Log() = default;
@@ -202,9 +202,10 @@
   return false;
 }
 
-bool Log::EnableLogChannel(lldb::StreamSP &log_stream_sp, uint32_t log_options,
-                           const char *channel, const char **categories,
-                           Stream &error_stream) {
+bool Log::EnableLogChannel(
+    const std::shared_ptr<llvm::raw_ostream> &log_stream_sp,
+    uint32_t log_options, const char *channel, const char **categories,
+    Stream &error_stream) {
   Log::Callbacks log_callbacks;
   if (Log::GetLogChannelCallbacks(ConstString(channel), log_callbacks)) {
     log_callbacks.enable(log_stream_sp, log_options, categories, &error_stream);
@@ -226,8 +227,9 @@
   }
 }
 
-void Log::EnableAllLogChannels(StreamSP &log_stream_sp, uint32_t log_options,
-                               const char **categories, Stream *feedback_strm) {
+void Log::EnableAllLogChannels(
+    const std::shared_ptr<llvm::raw_ostream> &log_stream_sp,
+    uint32_t log_options, const char **categories, Stream *feedback_strm) {
   CallbackMap &callback_map = GetCallbackMap();
   CallbackMapIter pos, end = callback_map.end();
 
@@ -355,18 +357,18 @@
 void Log::WriteMessage(const std::string &message) {
   // Make a copy of our stream shared pointer in case someone disables our
   // log while we are logging and releases the stream
-  StreamSP stream_sp(m_stream_sp);
+  auto stream_sp = m_stream_sp;
   if (!stream_sp)
     return;
 
   if (m_options.Test(LLDB_LOG_OPTION_THREADSAFE)) {
     static std::recursive_mutex g_LogThreadedMutex;
     std::lock_guard<std::recursive_mutex> guard(g_LogThreadedMutex);
-    stream_sp->PutCString(message.c_str());
-    stream_sp->Flush();
+    *stream_sp << message;
+    stream_sp->flush();
   } else {
-    stream_sp->PutCString(message.c_str());
-    stream_sp->Flush();
+    *stream_sp << message;
+    stream_sp->flush();
   }
 }