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] ";
}
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()
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
}
// ----------------------------------------------------------------------------
{
switch ( level ) {
case wxLOG_Info:
- case wxLOG_Message:
if ( GetVerbose() )
+ case wxLOG_Message:
if ( !m_bErrors ) {
m_aMessages.Add(szString);
m_bHasMessages = TRUE;
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:
// 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);
#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 ) ) {