X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/71debe95b622d4a0da22b0af69a0c28da8e33034..27db95f05459cad75e705f15750bf4d7d7666713:/src/common/log.cpp diff --git a/src/common/log.cpp b/src/common/log.cpp index 93842ef100..02b83693bf 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -6,7 +6,7 @@ // Created: 29/01/98 // RCS-ID: $Id$ // Copyright: (c) 1998 Vadim Zeitlin -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -65,6 +65,11 @@ #include "wx/mac/private.h" // includes mac headers #endif +#if defined(__MWERKS__) && wxUSE_UNICODE + #include +#endif + + // ---------------------------------------------------------------------------- // non member functions // ---------------------------------------------------------------------------- @@ -159,17 +164,22 @@ IMPLEMENT_LOG_FUNCTION(Message) IMPLEMENT_LOG_FUNCTION(Info) IMPLEMENT_LOG_FUNCTION(Status) +void wxSafeShowMessage(const wxString& title, const wxString& text) +{ +#ifdef __WINDOWS__ + ::MessageBox(NULL, text, title, MB_OK | MB_ICONSTOP); +#else + wxFprintf(stderr, _T("%s: %s\n"), title.c_str(), text.c_str()); +#endif +} + // fatal errors can't be suppressed nor handled by the custom log target and // always terminate the program void wxVLogFatalError(const wxChar *szFormat, va_list argptr) { wxVsnprintf(s_szBuf, s_szBufSize, szFormat, argptr); -#if wxUSE_GUI - wxMessageBox(s_szBuf, _("Fatal Error"), wxID_OK | wxICON_STOP); -#else - wxFprintf(stderr, _("Fatal error: %s\n"), s_szBuf); -#endif + wxSafeShowMessage(_T("Fatal Error"), s_szBuf); abort(); } @@ -346,7 +356,6 @@ void WXDLLEXPORT wxLogSysError(long lErrCode, const wxChar *szFormat, ...) wxLog::wxLog() { - m_bHasMessages = FALSE; } wxChar *wxLog::SetLogBuffer( wxChar *buf, size_t size) @@ -488,8 +497,7 @@ void wxLog::DoLogString(const wxChar *WXUNUSED(szString), time_t WXUNUSED(t)) void wxLog::Flush() { - // remember that we don't have any more messages to show - m_bHasMessages = FALSE; + // nothing to do here } // ---------------------------------------------------------------------------- @@ -504,9 +512,8 @@ wxLogStderr::wxLogStderr(FILE *fp) m_fp = fp; } -#if defined(__WXMAC__) && !defined(__DARWIN__) && (__MWERKS__ > 0x5300) +#if defined(__WXMAC__) && !defined(__DARWIN__) && defined(__MWERKS__) && (__MWERKS__ >= 0x2400) -#if !TARGET_API_MAC_CARBON // MetroNub stuff doesn't seem to work in CodeWarrior 5.3 Carbon builds... #ifndef __MetroNubUtils__ @@ -689,9 +696,7 @@ OSErr ClearWatchPoint (WatchPointIDT watchPointID) } #endif -#endif // !TARGET_API_MAC_CARBON - -#endif // defined(__WXMAC__) && !defined(__DARWIN__) && (__MWERKS__ > 0x5300) +#endif // defined(__WXMAC__) && !defined(__DARWIN__) && (__MWERKS__ >= 0x2400) void wxLogStderr::DoLogString(const wxChar *szString, time_t WXUNUSED(t)) { @@ -704,20 +709,25 @@ void wxLogStderr::DoLogString(const wxChar *szString, time_t WXUNUSED(t)) fflush(m_fp); // under Windows, programs usually don't have stderr at all, so show the - // messages also under debugger - unless it's a console program + // messages also under debugger (unless it's a console program which does + // have stderr or unless this is a file logger which doesn't use stderr at + // all) #if defined(__WXMSW__) && wxUSE_GUI && !defined(__WXMICROWIN__) - str += wxT("\r\n") ; - OutputDebugString(str.c_str()); + if ( m_fp == stderr ) + { + str += wxT("\r\n") ; + OutputDebugString(str.c_str()); + } #endif // MSW + #if defined(__WXMAC__) && !defined(__DARWIN__) && wxUSE_GUI Str255 pstr ; - strcpy( (char*) pstr , str.c_str() ) ; - strcat( (char*) pstr , ";g" ) ; - c2pstr( (char*) pstr ) ; + wxString output = str + wxT(";g") ; + wxMacStringToPascal( output.c_str() , pstr ) ; Boolean running = false ; -#if !TARGET_API_MAC_CARBON && (__MWERKS__ > 0x5300) +#if defined(__MWERKS__) && (__MWERKS__ >= 0x2400) if ( IsMWDebuggerRunning() && AmIBeingMWDebugged() ) { @@ -742,6 +752,7 @@ void wxLogStderr::DoLogString(const wxChar *szString, time_t WXUNUSED(t)) // ---------------------------------------------------------------------------- #if wxUSE_STD_IOSTREAM +#include "wx/ioswrap.h" wxLogStream::wxLogStream(wxSTD ostream *ostr) { if ( ostr == NULL ) @@ -791,7 +802,7 @@ void wxLogChain::Flush() if ( m_logOld ) m_logOld->Flush(); - // be careful to avoid inifinite recursion + // be careful to avoid infinite recursion if ( m_logNew && m_logNew != this ) m_logNew->Flush(); } @@ -843,6 +854,8 @@ bool wxLog::ms_doLog = TRUE; bool wxLog::ms_bAutoCreate = TRUE; bool wxLog::ms_bVerbose = FALSE; +wxLogLevel wxLog::ms_logLevel = wxLOG_Max; // log everything by default + size_t wxLog::ms_suspendCount = 0; #if wxUSE_GUI