X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8907154c1a8a6882c6797d1f16393ddfb23e7f3a..9804c4d95c3c8abb492e24f5f7e989016fee53f1:/include/wx/log.h?ds=inline diff --git a/include/wx/log.h b/include/wx/log.h index 78c6144245..09c20bf71c 100644 --- a/include/wx/log.h +++ b/include/wx/log.h @@ -121,13 +121,6 @@ public: // ctor wxLog(){} - // Internal buffer. - - // Allow replacement of the fixed size static buffer with - // a user allocated one. Pass in NULL to restore the - // built in static buffer. - static wxChar *SetLogBuffer( wxChar *buf, size_t size = 0 ); - // these functions allow to completely disable all log messages // is logging disabled now? @@ -135,19 +128,11 @@ public: // change the flag state, return the previous one static bool EnableLogging(bool doIt = true) - { bool doLogOld = ms_doLog; ms_doLog = doIt; return doLogOld; } + { bool doLogOld = ms_doLog; ms_doLog = doIt; return doLogOld; } // static sink function - see DoLog() for function to overload in the // derived classes - static void OnLog(wxLogLevel level, const wxChar *szString, time_t t) - { - if ( IsEnabled() && ms_logLevel >= level ) - { - wxLog *pLogger = GetActiveTarget(); - if ( pLogger ) - pLogger->DoLog(level, szString, t); - } - } + static void OnLog(wxLogLevel level, const wxChar *szString, time_t t); // message buffering @@ -195,12 +180,20 @@ public: // current is NULL? static void DontCreateOnDemand(); + // log the count of repeating messages instead of logging the messages + // multiple times + static void SetRepetitionCounting(bool bRepetCounting = true) + { ms_bRepetCounting = bRepetCounting; } + + // gets duplicate counting status + static bool GetRepetitionCounting() { return ms_bRepetCounting; } + // trace mask (see wxTraceXXX constants for details) static void SetTraceMask(wxTraceMask ulMask) { ms_ulTraceMask = ulMask; } // add string trace mask static void AddTraceMask(const wxString& str) - { ms_aTraceMasks.push_back(str); } + { ms_aTraceMasks.push_back(str); } // add string trace mask static void RemoveTraceMask(const wxString& str); @@ -242,12 +235,17 @@ public: static void TimeStamp(wxString *str); // make dtor virtual for all derived classes - virtual ~wxLog() { } + virtual ~wxLog(); // this method exists for backwards compatibility only, don't use bool HasPendingMessages() const { return true; } +#if WXWIN_COMPATIBILITY_2_6 + // this function doesn't do anything any more, don't call it + wxDEPRECATED( static wxChar *SetLogBuffer(wxChar *buf, size_t size = 0) ); +#endif + protected: // the logging functions that can be overriden @@ -259,10 +257,23 @@ protected: // you override DoLog() you might not need it at all virtual void DoLogString(const wxChar *szString, time_t t); + // log a line containing the number of times the previous message was + // repeated + // returns: the number + static unsigned DoLogNumberOfRepeats(); + private: // static variables // ---------------- + // traditional behaviour or counting repetitions + 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 time_t ms_prevTimeStamp;// timestamp of the previous message + static wxLogLevel ms_prevLevel; // level of the previous message + static wxLog *ms_pLogger; // currently active log sink static bool ms_doLog; // false => all logging disabled static bool ms_bAutoCreate; // create new log targets on demand? @@ -284,8 +295,6 @@ private: // "trivial" derivations of wxLog // ---------------------------------------------------------------------------- -#if wxABI_VERSION > 20601 - // log everything to a buffer class WXDLLIMPEXP_BASE wxLogBuffer : public wxLog { @@ -309,7 +318,6 @@ private: DECLARE_NO_COPY_CLASS(wxLogBuffer) }; -#endif // wxABI_VERSION // log everything to a "FILE *", stderr by default class WXDLLIMPEXP_BASE wxLogStderr : public wxLog @@ -505,6 +513,7 @@ public: #define wxTRACE_OleCalls wxEmptyString // OLE interface calls #endif // wxUSE_LOG/!wxUSE_LOG + #define DECLARE_LOG_FUNCTION2(level, argclass, arg) \ DECLARE_LOG_FUNCTION2_EXP(level, argclass, arg, WXDLLIMPEXP_BASE) @@ -540,7 +549,7 @@ DECLARE_LOG_FUNCTION(SysError); DECLARE_LOG_FUNCTION2(SysError, long, lErrCode); // debug functions do nothing in release mode -#if wxUSE_LOG_DEBUG +#if wxUSE_LOG && wxUSE_LOG_DEBUG DECLARE_LOG_FUNCTION(Debug); // there is no more unconditional LogTrace: it is not different from @@ -555,17 +564,24 @@ DECLARE_LOG_FUNCTION2(SysError, long, lErrCode); // wxLog::GetActive()->GetTraceMask() -- it's deprecated in favour of // string identifiers DECLARE_LOG_FUNCTION2(Trace, wxTraceMask, mask); -#else //!debug +#else //!debug || !wxUSE_LOG // these functions do nothing in release builds + #define wxVLogDebug(fmt, valist) + #define wxVLogTrace(mask, fmt, valist) + + #ifdef HAVE_VARIADIC_MACROS + // unlike the inline functions below, this completely removes the + // wxLogXXX calls from the object file: + #define wxLogDebug(fmt, ...) + #define wxLogTrace(mask, fmt, ...) + #else // !HAVE_VARIADIC_MACROS // note that leaving out "fmt" in the vararg functions provokes a warning // from SGI CC: "the last argument of the varargs function is unnamed" - inline void wxVLogDebug(const wxChar *, va_list) { } inline void wxLogDebug(const wxChar *fmt, ...) { wxUnusedVar(fmt); } - inline void wxVLogTrace(wxTraceMask, const wxChar *, va_list) { } inline void wxLogTrace(wxTraceMask, const wxChar *fmt, ...) { wxUnusedVar(fmt); } - inline void wxVLogTrace(const wxChar *, const wxChar *, va_list) { } inline void wxLogTrace(const wxChar *, const wxChar *fmt, ...) { wxUnusedVar(fmt); } + #endif // HAVE_VARIADIC_MACROS/!HAVE_VARIADIC_MACROS #endif // debug/!debug // wxLogFatalError helper: show the (fatal) error to the user in a safe way, @@ -596,8 +612,8 @@ wxSafeShowMessage(const wxString& title, const wxString& text); #define wxLogLastError(api) wxLogApiError(api, wxSysErrorCode()) #else //!debug - inline void wxLogApiError(const wxChar *, long) { } - inline void wxLogLastError(const wxChar *) { } + #define wxLogApiError(api, err) + #define wxLogLastError(api) #endif //debug/!debug // wxCocoa has additiional trace masks