]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/log.h
fix comparison of BYTE variable with -1 after last commit
[wxWidgets.git] / include / wx / log.h
index 41a4b86faeabb6038f3a6d152308237d5ee23ee1..a4d800e62342da52523abad8ac21f70f957d5cbb 100644 (file)
 
 #include "wx/defs.h"
 
+#if wxUSE_THREADS
+    class WXDLLIMPEXP_FWD_BASE wxCriticalSection;
+#endif
+
 // ----------------------------------------------------------------------------
 // common constants for use in wxUSE_LOG/!wxUSE_LOG
 // ----------------------------------------------------------------------------
@@ -301,20 +305,28 @@ protected:
     #define wxSUPPRESS_DOLOGSTRING_HIDE_WARNING()
 #endif
 
-    // log a line containing the number of times the previous message was
-    // repeated
-    // returns: the number
-    static unsigned DoLogNumberOfRepeats();
+    // log a message indicating the number of times the previous message was
+    // repeated if ms_prevCounter > 0, does nothing otherwise; return the old
+    // value of ms_prevCounter
+    unsigned LogLastRepeatIfNeeded();
 
 private:
+    // implement of LogLastRepeatIfNeeded(): it assumes that the
+    // caller had already locked ms_prevCS
+    unsigned LogLastRepeatIfNeededUnlocked();
+
     // static variables
     // ----------------
 
-    // traditional behaviour or counting repetitions
+    // if true, don't log the same message multiple times, only log it once
+    // with the number of times it was repeated
     static bool        ms_bRepetCounting;
+
+#if wxUSE_THREADS
+    static wxCriticalSection ms_prevCS; // protects the ms_prev values below
+#endif
     static wxString    ms_prevString;   // previous message that was logged
-    // how many times the previous message was logged
-    static unsigned    ms_prevCounter;
+    static unsigned    ms_prevCounter;  // how many times it was repeated
     static time_t      ms_prevTimeStamp;// timestamp of the previous message
     static wxLogLevel  ms_prevLevel;    // level of the previous message
 
@@ -619,6 +631,13 @@ WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0);
     #define WX_WATCOM_ONLY_CODE( x )
 #endif
 
+#if defined(__WATCOMC__) || defined(__MINGW32__)
+    // Mingw has similar problem with wxLogSysError:
+    #define WX_WATCOM_OR_MINGW_ONLY_CODE( x )  x
+#else
+    #define WX_WATCOM_OR_MINGW_ONLY_CODE( x )
+#endif
+
 // log functions do nothing at all
 #define DECLARE_LOG_FUNCTION(level)                                         \
     WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 1, (const wxString&))           \
@@ -632,7 +651,7 @@ WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0);
 
 #define DECLARE_LOG_FUNCTION2_EXP(level, argclass, arg, expdecl)            \
     WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const wxString&)) \
-    WX_WATCOM_ONLY_CODE(                                                    \
+    WX_WATCOM_OR_MINGW_ONLY_CODE(                                           \
         WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const char*)) \
         WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const wchar_t*)) \
         WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const wxCStrData&)) \