X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7b1bf3ad2d419ea08ec29a39ed4c96c33a2f12e1..7e08bc5acd8ee4e2f0756f50bf98937a118f9951:/include/wx/log.h?ds=sidebyside diff --git a/include/wx/log.h b/include/wx/log.h index 9166b7ee50..cfe6b679e4 100644 --- a/include/wx/log.h +++ b/include/wx/log.h @@ -51,9 +51,11 @@ typedef unsigned long wxLogLevel; #include "wx/arrstr.h" +#ifndef __WXPALMOS5__ #ifndef __WXWINCE__ #include // for time_t #endif +#endif // ! __WXPALMOS5__ #include "wx/dynarray.h" @@ -70,10 +72,10 @@ typedef unsigned long wxLogLevel; // ---------------------------------------------------------------------------- #if wxUSE_GUI - class WXDLLIMPEXP_CORE wxTextCtrl; - class WXDLLIMPEXP_CORE wxLogFrame; - class WXDLLIMPEXP_CORE wxFrame; - class WXDLLIMPEXP_CORE wxWindow; + class WXDLLIMPEXP_FWD_CORE wxTextCtrl; + class WXDLLIMPEXP_FWD_CORE wxLogFrame; + class WXDLLIMPEXP_FWD_CORE wxFrame; + class WXDLLIMPEXP_FWD_CORE wxWindow; #endif // wxUSE_GUI // ---------------------------------------------------------------------------- @@ -196,8 +198,7 @@ public: static void SetTraceMask(wxTraceMask ulMask) { ms_ulTraceMask = ulMask; } // add string trace mask - static void AddTraceMask(const wxString& str) - { ms_aTraceMasks.push_back(str); } + static void AddTraceMask(const wxString& str); // add string trace mask static void RemoveTraceMask(const wxString& str); @@ -205,8 +206,9 @@ public: // remove all string trace masks static void ClearTraceMasks(); - // get string trace masks - static const wxArrayString &GetTraceMasks() { return ms_aTraceMasks; } + // get string trace masks: note that this is MT-unsafe if other threads can + // call AddTraceMask() concurrently + static const wxArrayString& GetTraceMasks() { return ms_aTraceMasks; } // sets the time stamp string format: this is used as strftime() format // string for the log targets which add time stamps to the messages; set @@ -301,20 +303,25 @@ 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; + 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 @@ -362,7 +369,7 @@ protected: private: wxString m_str; - DECLARE_NO_COPY_CLASS(wxLogBuffer) + wxDECLARE_NO_COPY_CLASS(wxLogBuffer); }; @@ -371,7 +378,7 @@ class WXDLLIMPEXP_BASE wxLogStderr : public wxLog { public: // redirect log output to a FILE - wxLogStderr(FILE *fp = (FILE *) NULL); + wxLogStderr(FILE *fp = NULL); protected: // implement sink function @@ -381,7 +388,7 @@ protected: FILE *m_fp; - DECLARE_NO_COPY_CLASS(wxLogStderr) + wxDECLARE_NO_COPY_CLASS(wxLogStderr); }; #if wxUSE_STD_IOSTREAM @@ -485,7 +492,7 @@ private: // do we pass the messages to the old logger? bool m_bPassMessages; - DECLARE_NO_COPY_CLASS(wxLogChain) + wxDECLARE_NO_COPY_CLASS(wxLogChain); }; // a chain log target which uses itself as the new logger @@ -498,7 +505,7 @@ public: wxLogInterposer(); private: - DECLARE_NO_COPY_CLASS(wxLogInterposer) + wxDECLARE_NO_COPY_CLASS(wxLogInterposer); }; // a temporary interposer which doesn't destroy the old log target @@ -510,7 +517,7 @@ public: wxLogInterposerTemp(); private: - DECLARE_NO_COPY_CLASS(wxLogInterposerTemp) + wxDECLARE_NO_COPY_CLASS(wxLogInterposerTemp); }; #if wxUSE_GUI @@ -619,6 +626,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 +646,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&)) \ @@ -684,7 +698,7 @@ DECLARE_LOG_FUNCTION(Status); #if wxUSE_GUI // this one is the same as previous except that it allows to explicitly - class WXDLLEXPORT wxFrame; + class WXDLLIMPEXP_FWD_CORE wxFrame; // specify the frame to which the output should go DECLARE_LOG_FUNCTION2_EXP(Status, wxFrame *, pFrame, WXDLLIMPEXP_CORE); #endif // wxUSE_GUI @@ -737,7 +751,14 @@ DECLARE_LOG_FUNCTION2(SysError, unsigned long, lErrCode); // empty functions if their parameters are complicated enough, but by // defining them as an empty inline function we ensure that even dumbest // compilers optimise them away +#ifdef __BORLANDC__ + // but Borland gives "W8019: Code has no effect" for wxLogNop() so we need + // to define it differently for it to avoid these warnings (same problem as + // with wxUnusedVar()) + #define wxLogNop() { } +#else inline void wxLogNop() { } +#endif #define wxVLogDebug(fmt, valist) wxLogNop() #define wxVLogTrace(mask, fmt, valist) wxLogNop()