X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9838df2cefc5b368bb11f98c784ecc78f45ecaf7..22b4634c61ab10d4305261f4b637e1c871c8b1b0:/src/common/log.cpp diff --git a/src/common/log.cpp b/src/common/log.cpp index f28e32fc80..686cd75754 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -239,7 +239,14 @@ void WXDLLEXPORT wxLogSysError(long lErrCode, const char *szFormat, ...) wxLog::wxLog() { m_bHasMessages = FALSE; - m_bVerbose = FALSE; + + // enable verbose messages by default in the debug builds +#ifdef __WXDEBUG__ + m_bVerbose = TRUE; +#else // release + m_bVerbose = FALSE; +#endif // debug/release + m_szTimeFormat = "[%d/%b/%y %H:%M:%S] "; } @@ -358,7 +365,7 @@ void wxLog::DoLog(wxLogLevel level, const char *szString) void wxLog::DoLogString(const char *WXUNUSED(szString)) { - wxFAIL_MSG(_("DoLogString must be overrided if it's called.")); + wxFAIL_MSG("DoLogString must be overriden if it's called."); } void wxLog::Flush() @@ -380,9 +387,17 @@ wxLogStderr::wxLogStderr(FILE *fp) void wxLogStderr::DoLogString(const char *szString) { - fputs(szString, m_fp); - fputc('\n', m_fp); + wxString str(szString); + str << '\n'; + + fputs(str, m_fp); fflush(m_fp); + + // under Windows, programs usually don't have stderr at all, so make show the + // messages also under debugger +#ifdef __WXMSW__ + OutputDebugString(str + '\r'); +#endif // MSW } // ---------------------------------------------------------------------------- @@ -481,8 +496,8 @@ void wxLogGui::DoLog(wxLogLevel level, const char *szString) { switch ( level ) { case wxLOG_Info: - case wxLOG_Message: if ( GetVerbose() ) + case wxLOG_Message: if ( !m_bErrors ) { m_aMessages.Add(szString); m_bHasMessages = TRUE; @@ -517,18 +532,14 @@ void wxLogGui::DoLog(wxLogLevel level, const char *szString) OutputDebugString(strTime + szString + "\n\r"); #else // send them to stderr - /* fprintf(stderr, "%s %s: %s\n", strTime.c_str(), - level == wxLOG_Trace ? _("Trace") : _("Debug"), - szString); - */ - fprintf(stderr, "%s\n", + level == wxLOG_Trace ? "Trace" : "Debug", szString); fflush(stderr); #endif } - #endif + #endif // __WXDEBUG__ break; case wxLOG_FatalError: @@ -977,13 +988,24 @@ void wxOnAssert(const char *szFile, int nLine, const char *szMsg) // He-e-e-e-elp!! we're trapped in endless loop Trap(); + s_bInAssert = FALSE; + return; } s_bInAssert = TRUE; char szBuf[LOG_BUFFER_SIZE]; - sprintf(szBuf, _("Assert failed in file %s at line %d"), szFile, nLine); + + // make life easier for people using VC++ IDE: clicking on the message will + // take us immediately to the place of the failed assert +#ifdef __VISUALC__ + sprintf(szBuf, "%s(%d): assert failed", szFile, nLine); +#else // !VC++ + // make the error message more clear for all the others + sprintf(szBuf, "Assert failed in file %s at line %d", szFile, nLine); +#endif // VC/!VC + if ( szMsg != NULL ) { strcat(szBuf, ": "); strcat(szBuf, szMsg); @@ -999,9 +1021,9 @@ void wxOnAssert(const char *szFile, int nLine, const char *szMsg) #if wxUSE_NOGUI Trap(); #else - strcat(szBuf, _("\nDo you want to stop the program?" - "\nYou can also choose [Cancel] to suppress " - "further warnings.")); + strcat(szBuf, "\nDo you want to stop the program?" + "\nYou can also choose [Cancel] to suppress " + "further warnings."); switch ( wxMessageBox(szBuf, _("Debug"), wxYES_NO | wxCANCEL | wxICON_STOP ) ) {