X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/47fe7ff3821c632b490b16da6b5113f127905a23..601398b9b1e63109f44af34ff79bc558fe929b4d:/include/wx/log.h diff --git a/include/wx/log.h b/include/wx/log.h index 4b4f745408..a4d800e623 100644 --- a/include/wx/log.h +++ b/include/wx/log.h @@ -14,6 +14,10 @@ #include "wx/defs.h" +#if wxUSE_THREADS + class WXDLLIMPEXP_FWD_BASE wxCriticalSection; +#endif + // ---------------------------------------------------------------------------- // common constants for use in wxUSE_LOG/!wxUSE_LOG // ---------------------------------------------------------------------------- @@ -70,10 +74,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 // ---------------------------------------------------------------------------- @@ -208,11 +212,14 @@ public: // get string trace masks static const wxArrayString &GetTraceMasks() { return ms_aTraceMasks; } - // sets the timestamp string: this is used as strftime() format string - // for the log targets which add time stamps to the messages - set it - // to NULL to disable time stamping completely. + // 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 + // it to empty string to disable time stamping completely. static void SetTimestamp(const wxString& ts) { ms_timestamp = ts; } + // disable time stamping of log messages + static void DisableTimestamp() { SetTimestamp(wxEmptyString); } + // accessors @@ -279,22 +286,47 @@ protected: time_t WXUNUSED(t)) {} virtual void DoLogString(const wchar_t *WXUNUSED(szString), time_t WXUNUSED(t)) {} +#endif // WXWIN_COMPATIBILITY_2_8 + + // this macro should be used in the derived classes to avoid warnings about + // hiding the other DoLog() overloads when overriding DoLog(wxString) -- + // but don't use it with MSVC which doesn't give this warning but does give + // warning when a deprecated function is overridden +#if WXWIN_COMPATIBILITY_2_8 && !defined(__VISUALC__) + #define wxSUPPRESS_DOLOG_HIDE_WARNING() \ + virtual void DoLog(wxLogLevel, const char *, time_t) { } \ + virtual void DoLog(wxLogLevel, const wchar_t *, time_t) { } + + #define wxSUPPRESS_DOLOGSTRING_HIDE_WARNING() \ + virtual void DoLogString(const char *, time_t) { } \ + virtual void DoLogString(const wchar_t *, time_t) { } +#else + #define wxSUPPRESS_DOLOG_HIDE_WARNING() + #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 @@ -336,6 +368,9 @@ protected: virtual void DoLog(wxLogLevel level, const wxString& szString, time_t t); virtual void DoLogString(const wxString& szString, time_t t); + wxSUPPRESS_DOLOG_HIDE_WARNING() + wxSUPPRESS_DOLOGSTRING_HIDE_WARNING() + private: wxString m_str; @@ -354,6 +389,8 @@ protected: // implement sink function virtual void DoLogString(const wxString& szString, time_t t); + wxSUPPRESS_DOLOGSTRING_HIDE_WARNING() + FILE *m_fp; DECLARE_NO_COPY_CLASS(wxLogStderr) @@ -372,6 +409,8 @@ protected: // implement sink function virtual void DoLogString(const wxString& szString, time_t t); + wxSUPPRESS_DOLOGSTRING_HIDE_WARNING() + // using ptr here to avoid including from this file wxSTD ostream *m_ostr; }; @@ -446,6 +485,8 @@ protected: // pass the chain to the old logger if needed virtual void DoLog(wxLogLevel level, const wxString& szString, time_t t); + wxSUPPRESS_DOLOG_HIDE_WARNING() + private: // the current log target wxLog *m_logNew; @@ -590,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&)) \ @@ -603,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&)) \ @@ -655,7 +703,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