]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/log.cpp
don't provide unnecessary (as default) arguments to wxPen ctor, this incidentally...
[wxWidgets.git] / src / common / log.cpp
index 250b7b3924495804bc89de222025249efa338ac3..bbd0c5829223b746c5425ef9dc91ac8af0699dd6 100644 (file)
 
 #include <stdlib.h>
 
+#ifndef __WXPALMOS5__
 #ifndef __WXWINCE__
 #include <time.h>
 #else
 #include "wx/msw/wince/time.h"
 #endif
+#endif /* ! __WXPALMOS5__ */
 
 #if defined(__WINDOWS__)
     #include "wx/msw/private.h" // includes windows.h
@@ -490,7 +492,17 @@ unsigned wxLog::LogLastRepeatIfNeededUnlocked()
 
 wxLog::~wxLog()
 {
-    LogLastRepeatIfNeeded();
+    // Flush() must be called before destroying the object as otherwise some
+    // messages could be lost
+    if ( ms_prevCounter )
+    {
+        wxMessageOutputDebug().Printf
+        (
+            wxS("Last repeated message (\"%s\", %lu times) wasn't output"),
+            ms_prevString,
+            ms_prevCounter
+        );
+    }
 }
 
 /* static */
@@ -606,8 +618,17 @@ void wxLog::DoCreateOnDemand()
     ms_bAutoCreate = true;
 }
 
+void wxLog::AddTraceMask(const wxString& str)
+{
+    wxCRIT_SECT_LOCKER(lock, ms_traceCS);
+
+    ms_aTraceMasks.push_back(str);
+}
+
 void wxLog::RemoveTraceMask(const wxString& str)
 {
+    wxCRIT_SECT_LOCKER(lock, ms_traceCS);
+
     int index = ms_aTraceMasks.Index(str);
     if ( index != wxNOT_FOUND )
         ms_aTraceMasks.RemoveAt((size_t)index);
@@ -615,6 +636,8 @@ void wxLog::RemoveTraceMask(const wxString& str)
 
 void wxLog::ClearTraceMasks()
 {
+    wxCRIT_SECT_LOCKER(lock, ms_traceCS);
+
     ms_aTraceMasks.Clear();
 }
 
@@ -705,16 +728,21 @@ void wxLog::DoLogString(const wxString& szString, time_t t)
 
 void wxLog::Flush()
 {
-    // nothing to do here
+    LogLastRepeatIfNeeded();
 }
 
 /*static*/ bool wxLog::IsAllowedTraceMask(const wxString& mask)
 {
+    wxCRIT_SECT_LOCKER(lock, ms_traceCS);
+
     for ( wxArrayString::iterator it = ms_aTraceMasks.begin(),
                                   en = ms_aTraceMasks.end();
          it != en; ++it )
+    {
         if ( *it == mask)
             return true;
+    }
+
     return false;
 }
 
@@ -912,7 +940,8 @@ wxLogInterposerTemp::wxLogInterposerTemp()
 // ----------------------------------------------------------------------------
 
 #if wxUSE_THREADS
-wxCriticalSection wxLog::ms_prevCS;
+wxCriticalSection wxLog::ms_prevCS,
+                  wxLog::ms_traceCS;
 #endif // wxUSE_THREADS
 bool            wxLog::ms_bRepetCounting = false;
 wxString        wxLog::ms_prevString;