Fix bugs attempting to write to API log after it has been
disabled.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@117493 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBCommandInterpreter.cpp b/source/API/SBCommandInterpreter.cpp
index f6a95f9..cb2dd74 100644
--- a/source/API/SBCommandInterpreter.cpp
+++ b/source/API/SBCommandInterpreter.cpp
@@ -87,6 +87,8 @@
         result->SetStatus (eReturnStatusFailed);
     }
 
+    // We need to get the value again, in case the command disabled the log!
+    log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
     if (log)
     {
         SBStream sstr;
diff --git a/source/API/SBListener.cpp b/source/API/SBListener.cpp
index 0062746..bc118e5 100644
--- a/source/API/SBListener.cpp
+++ b/source/API/SBListener.cpp
@@ -119,7 +119,6 @@
 bool
 SBListener::WaitForEvent (uint32_t num_seconds, SBEvent &event)
 {
-    Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
 
     //if (log)
     //{
@@ -141,6 +140,7 @@
         if (m_opaque_ptr->WaitForEvent (time_value.IsValid() ? &time_value : NULL, event_sp))
         {
             event.reset (event_sp);
+            Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
             if (log)
                 log->Printf ("SBListener::WaitForEvent (this.obj=%p, num_seconds=%d, event.sp=%p) => 'true'",
                              m_opaque_ptr, num_seconds, event.get());
@@ -148,6 +148,7 @@
         }
     }
 
+    Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
     if (log)
         log->Printf ("SBListener::WaitForEvent (this.obj=%p, num_seconds=%d, event.sp=%p) => 'false'",
                      m_opaque_ptr, num_seconds, event.get());