X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/83250f1a2b8c16bd69f0cdea7cf8ffe658d66b6d..f46ad98f0df1e1b073a484cb34a91e2e1278fdb7:/include/wx/log.h diff --git a/include/wx/log.h b/include/wx/log.h index 13230917c6..71be9b337b 100644 --- a/include/wx/log.h +++ b/include/wx/log.h @@ -12,10 +12,6 @@ #ifndef _WX_LOG_H_ #define _WX_LOG_H_ -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma interface "log.h" -#endif - #include "wx/defs.h" // ---------------------------------------------------------------------------- @@ -143,15 +139,7 @@ public: // 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 @@ -199,6 +187,14 @@ 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; } @@ -246,7 +242,7 @@ 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 @@ -263,10 +259,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? @@ -311,6 +320,7 @@ private: DECLARE_NO_COPY_CLASS(wxLogBuffer) }; + // log everything to a "FILE *", stderr by default class WXDLLIMPEXP_BASE wxLogStderr : public wxLog { @@ -505,6 +515,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 +551,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,14 +566,17 @@ 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 + + // 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 *, ...) { } + inline void wxLogDebug(const wxChar *fmt, ...) { wxUnusedVar(fmt); } inline void wxVLogTrace(wxTraceMask, const wxChar *, va_list) { } - inline void wxLogTrace(wxTraceMask, const wxChar *, ...) { } + 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 *, ...) { } + inline void wxLogTrace(const wxChar *, const wxChar *fmt, ...) { wxUnusedVar(fmt); } #endif // debug/!debug // wxLogFatalError helper: show the (fatal) error to the user in a safe way,