X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/34138703c3997ce676a1e713d9ff9eb020640da7..4c7e33c5ea8f4e68a1468333e26251d0271613b0:/include/wx/log.h?ds=inline diff --git a/include/wx/log.h b/include/wx/log.h index 85ec698967..afabcbac84 100644 --- a/include/wx/log.h +++ b/include/wx/log.h @@ -52,10 +52,18 @@ typedef unsigned long wxLogLevel; // ---------------------------------------------------------------------------- // forward declarations // ---------------------------------------------------------------------------- -class wxTextCtrl; -class wxLogFrame; -class wxFrame; -class ostream; +class WXDLLEXPORT wxTextCtrl; +class WXDLLEXPORT wxLogFrame; +class WXDLLEXPORT wxFrame; + +#if wxUSE_IOSTREAMH +# include +#else +# include +# ifdef _MSC_VER + using namespace std; +# endif +#endif // ---------------------------------------------------------------------------- // derive from this class to redirect (or suppress, or ...) log messages @@ -69,7 +77,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 +97,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 +164,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,12 +174,11 @@ 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 @@ -174,6 +188,8 @@ protected: ostream *m_ostr; }; +#ifndef wxUSE_NOGUI + // log everything to a text window (GUI only of course) class WXDLLEXPORT wxLogTextCtrl : public wxLogStream { @@ -255,6 +271,8 @@ private: wxLogFrame *m_pLogFrame; // the log frame }; +#endif // wxUSE_NOGUI + // ---------------------------------------------------------------------------- // /dev/null log target: suppress logging until this object goes out of scope // ---------------------------------------------------------------------------- @@ -276,7 +294,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: @@ -350,9 +368,6 @@ DECLARE_LOG_FUNCTION2(SysError, long lErrCode); // parts of the program only) WXDLLEXPORT_DATA(extern bool) g_bVerbose; -// fwd decl to avoid including iostream.h here -class ostream; - // ---------------------------------------------------------------------------- // get error code/error message from system in a portable way // ----------------------------------------------------------------------------