X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/470b7da353545369db1a4ecdbc673a496d9980c8..d069d02e1e27f6d924c3b28173ff81d87ec8b072:/include/wx/log.h diff --git a/include/wx/log.h b/include/wx/log.h index 50918b2c02..0c178347d9 100644 --- a/include/wx/log.h +++ b/include/wx/log.h @@ -9,8 +9,8 @@ // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// -#ifndef __LOGH__ -#define __LOGH__ +#ifndef _WX_LOG_H_ +#define _WX_LOG_H_ #ifdef __GNUG__ #pragma interface "log.h" @@ -69,7 +69,13 @@ public: // sink function static void OnLog(wxLogLevel level, const char *szString) - { if ( ms_pLogger != 0 ) ms_pLogger->DoLog(level, szString); } + { + wxLog *pLogger = GetActiveTarget(); + if ( pLogger ) + { + pLogger->DoLog(level, szString); + } + } // message buffering // flush shows all messages if they're not logged immediately @@ -83,11 +89,12 @@ public: // only one sink is active at each moment // get current log target, will call wxApp::CreateLogTarget() to create one - // if + // if none exists static wxLog *GetActiveTarget(); - // change log target, pLogger = NULL disables logging, + // change log target, pLogger = NULL disables logging. if bNoFlashOld is true, + // the old log target isn't flashed which might lead to loss of messages! // returns the previous log target - static wxLog *SetActiveTarget(wxLog *pLogger); + static wxLog *SetActiveTarget(wxLog *pLogger, bool bNoFlashOld = FALSE); // functions controlling the default wxLog behaviour // verbose mode is activated by standard command-line '-verbose' option @@ -149,7 +156,7 @@ class WXDLLEXPORT wxLogStderr : public wxLog { public: // redirect log output to a FILE - wxLogStderr(FILE *fp = NULL); + wxLogStderr(FILE *fp = (FILE *) NULL); private: // implement sink function @@ -159,11 +166,12 @@ private: }; // log everything to an "ostream", cerr by default +class ostream; class WXDLLEXPORT wxLogStream : public wxLog { public: // redirect log output to an ostream - wxLogStream(ostream *ostr = NULL); + wxLogStream(ostream *ostr = (ostream *) NULL); protected: // implement sink function @@ -275,7 +283,7 @@ class WXDLLEXPORT wxLogNull { public: // ctor saves old log target, dtor restores it - wxLogNull() { m_pPrevLogger = wxLog::SetActiveTarget(NULL); } + wxLogNull() { m_pPrevLogger = wxLog::SetActiveTarget((wxLog *)NULL, TRUE); } ~wxLogNull() { (void)wxLog::SetActiveTarget(m_pPrevLogger); } private: @@ -376,4 +384,4 @@ const char* WXDLLEXPORT wxSysErrorMsg(unsigned long nErrCode = 0); inline void wxLogLastError(const char *) { } #endif //debug/!debug -#endif //__LOGH__ +#endif // _WX_LOG_H_