1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Assorted wxLogXXX functions, and wxLog (sink for logs)
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #pragma implementation "log.h"
23 // For compilers that support precompilation, includes "wx.h".
24 #include "wx/wxprec.h"
32 #include "wx/window.h"
33 #include "wx/msw/private.h"
36 #include <wx/string.h>
40 #include <wx/msgdlg.h>
41 #include <wx/filedlg.h>
42 #include <wx/textctrl.h>
46 #include <wx/textfile.h>
50 // other standard headers
57 // Redefines OutputDebugString if necessary
58 #include "wx/msw/private.h"
63 // ----------------------------------------------------------------------------
64 // non member functions
65 // ----------------------------------------------------------------------------
67 // define this to enable wrapping of log messages
68 //#define LOG_PRETTY_WRAP
70 #ifdef LOG_PRETTY_WRAP
71 static void wxLogWrap(FILE *f
, const char *pszPrefix
, const char *psz
);
74 // ----------------------------------------------------------------------------
76 // ----------------------------------------------------------------------------
78 // we use a global variable to store the frame pointer for wxLogStatus - bad,
79 // but it's he easiest way
80 static wxFrame
*gs_pFrame
; // FIXME MT-unsafe
82 // ============================================================================
84 // ============================================================================
86 // ----------------------------------------------------------------------------
87 // implementation of Log functions
89 // NB: unfortunately we need all these distinct functions, we can't make them
90 // macros and not all compilers inline vararg functions.
91 // ----------------------------------------------------------------------------
93 // log functions can't allocate memory (LogError("out of memory...") should
94 // work!), so we use a static buffer for all log messages
95 #define LOG_BUFFER_SIZE (4096)
97 // static buffer for error messages (FIXME MT-unsafe)
98 static wxChar s_szBuf
[LOG_BUFFER_SIZE
];
100 // generic log function
101 void wxLogGeneric(wxLogLevel level
, const wxChar
*szFormat
, ...)
103 if ( wxLog::GetActiveTarget() != NULL
) {
105 va_start(argptr
, szFormat
);
106 wxVsprintf(s_szBuf
, szFormat
, argptr
);
109 wxLog::OnLog(level
, s_szBuf
, time(NULL
));
113 #define IMPLEMENT_LOG_FUNCTION(level) \
114 void wxLog##level(const wxChar *szFormat, ...) \
116 if ( wxLog::GetActiveTarget() != NULL ) { \
118 va_start(argptr, szFormat); \
119 wxVsprintf(s_szBuf, szFormat, argptr); \
122 wxLog::OnLog(wxLOG_##level, s_szBuf, time(NULL)); \
126 IMPLEMENT_LOG_FUNCTION(FatalError
)
127 IMPLEMENT_LOG_FUNCTION(Error
)
128 IMPLEMENT_LOG_FUNCTION(Warning
)
129 IMPLEMENT_LOG_FUNCTION(Message
)
130 IMPLEMENT_LOG_FUNCTION(Info
)
131 IMPLEMENT_LOG_FUNCTION(Status
)
133 // accepts an additional argument which tells to which frame the output should
135 void wxLogStatus(wxFrame
*pFrame
, const wxChar
*szFormat
, ...)
137 wxLog
*pLog
= wxLog::GetActiveTarget();
138 if ( pLog
!= NULL
) {
140 va_start(argptr
, szFormat
);
141 wxVsprintf(s_szBuf
, szFormat
, argptr
);
144 wxASSERT( gs_pFrame
== NULL
); // should be reset!
146 wxLog::OnLog(wxLOG_Status
, s_szBuf
, time(NULL
));
147 gs_pFrame
= (wxFrame
*) NULL
;
151 // same as info, but only if 'verbose' mode is on
152 void wxLogVerbose(const wxChar
*szFormat
, ...)
154 wxLog
*pLog
= wxLog::GetActiveTarget();
155 if ( pLog
!= NULL
&& pLog
->GetVerbose() ) {
157 va_start(argptr
, szFormat
);
158 wxVsprintf(s_szBuf
, szFormat
, argptr
);
161 wxLog::OnLog(wxLOG_Info
, s_szBuf
, time(NULL
));
167 #define IMPLEMENT_LOG_DEBUG_FUNCTION(level) \
168 void wxLog##level(const wxChar *szFormat, ...) \
170 if ( wxLog::GetActiveTarget() != NULL ) { \
172 va_start(argptr, szFormat); \
173 wxVsprintf(s_szBuf, szFormat, argptr); \
176 wxLog::OnLog(wxLOG_##level, s_szBuf, time(NULL)); \
180 void wxLogTrace(const wxChar
*mask
, const wxChar
*szFormat
, ...)
182 wxLog
*pLog
= wxLog::GetActiveTarget();
184 if ( pLog
!= NULL
&& wxLog::IsAllowedTraceMask(mask
) ) {
186 va_start(argptr
, szFormat
);
187 wxVsprintf(s_szBuf
, szFormat
, argptr
);
190 wxLog::OnLog(wxLOG_Trace
, s_szBuf
, time(NULL
));
194 void wxLogTrace(wxTraceMask mask
, const wxChar
*szFormat
, ...)
196 wxLog
*pLog
= wxLog::GetActiveTarget();
198 // we check that all of mask bits are set in the current mask, so
199 // that wxLogTrace(wxTraceRefCount | wxTraceOle) will only do something
200 // if both bits are set.
201 if ( pLog
!= NULL
&& ((pLog
->GetTraceMask() & mask
) == mask
) ) {
203 va_start(argptr
, szFormat
);
204 wxVsprintf(s_szBuf
, szFormat
, argptr
);
207 wxLog::OnLog(wxLOG_Trace
, s_szBuf
, time(NULL
));
212 #define IMPLEMENT_LOG_DEBUG_FUNCTION(level)
215 IMPLEMENT_LOG_DEBUG_FUNCTION(Debug
)
216 IMPLEMENT_LOG_DEBUG_FUNCTION(Trace
)
218 // wxLogSysError: one uses the last error code, for other you must give it
221 // common part of both wxLogSysError
222 void wxLogSysErrorHelper(long lErrCode
)
224 wxChar szErrMsg
[LOG_BUFFER_SIZE
/ 2];
225 wxSprintf(szErrMsg
, _(" (error %ld: %s)"), lErrCode
, wxSysErrorMsg(lErrCode
));
226 wxStrncat(s_szBuf
, szErrMsg
, WXSIZEOF(s_szBuf
) - wxStrlen(s_szBuf
));
228 wxLog::OnLog(wxLOG_Error
, s_szBuf
, time(NULL
));
231 void WXDLLEXPORT
wxLogSysError(const wxChar
*szFormat
, ...)
234 va_start(argptr
, szFormat
);
235 wxVsprintf(s_szBuf
, szFormat
, argptr
);
238 wxLogSysErrorHelper(wxSysErrorCode());
241 void WXDLLEXPORT
wxLogSysError(long lErrCode
, const wxChar
*szFormat
, ...)
244 va_start(argptr
, szFormat
);
245 wxVsprintf(s_szBuf
, szFormat
, argptr
);
248 wxLogSysErrorHelper(lErrCode
);
251 // ----------------------------------------------------------------------------
252 // wxLog class implementation
253 // ----------------------------------------------------------------------------
257 m_bHasMessages
= FALSE
;
259 // enable verbose messages by default in the debug builds
264 #endif // debug/release
267 wxLog
*wxLog::GetActiveTarget()
269 if ( ms_bAutoCreate
&& ms_pLogger
== NULL
) {
270 // prevent infinite recursion if someone calls wxLogXXX() from
271 // wxApp::CreateLogTarget()
272 static bool s_bInGetActiveTarget
= FALSE
;
273 if ( !s_bInGetActiveTarget
) {
274 s_bInGetActiveTarget
= TRUE
;
277 ms_pLogger
= new wxLogStderr
;
279 // ask the application to create a log target for us
280 if ( wxTheApp
!= NULL
)
281 ms_pLogger
= wxTheApp
->CreateLogTarget();
283 ms_pLogger
= new wxLogStderr
;
286 s_bInGetActiveTarget
= FALSE
;
288 // do nothing if it fails - what can we do?
295 wxLog
*wxLog::SetActiveTarget(wxLog
*pLogger
)
297 if ( ms_pLogger
!= NULL
) {
298 // flush the old messages before changing because otherwise they might
299 // get lost later if this target is not restored
303 wxLog
*pOldLogger
= ms_pLogger
;
304 ms_pLogger
= pLogger
;
309 void wxLog::RemoveTraceMask(const wxString
& str
)
311 int index
= ms_aTraceMasks
.Index(str
);
312 if ( index
!= wxNOT_FOUND
)
313 ms_aTraceMasks
.Remove((size_t)index
);
316 void wxLog::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
319 case wxLOG_FatalError
:
320 DoLogString(wxString(_("Fatal error: ")) + szString
, t
);
321 DoLogString(_("Program aborted."), t
);
327 DoLogString(wxString(_("Error: ")) + szString
, t
);
331 DoLogString(wxString(_("Warning: ")) + szString
, t
);
337 default: // log unknown log levels too
338 DoLogString(szString
, t
);
348 DoLogString(szString
, t
);
354 void wxLog::DoLogString(const wxChar
*WXUNUSED(szString
), time_t WXUNUSED(t
))
356 wxFAIL_MSG(_T("DoLogString must be overriden if it's called."));
364 // ----------------------------------------------------------------------------
365 // wxLogStderr class implementation
366 // ----------------------------------------------------------------------------
368 wxLogStderr::wxLogStderr(FILE *fp
)
376 void wxLogStderr::DoLogString(const wxChar
*szString
, time_t WXUNUSED(t
))
378 wxString
str(szString
);
381 fputs(str
.mb_str(), m_fp
);
384 // under Windows, programs usually don't have stderr at all, so make show the
385 // messages also under debugger
387 OutputDebugString(str
+ _T('\r'));
391 // ----------------------------------------------------------------------------
392 // wxLogStream implementation
393 // ----------------------------------------------------------------------------
395 #if wxUSE_STD_IOSTREAM
396 wxLogStream::wxLogStream(ostream
*ostr
)
404 void wxLogStream::DoLogString(const wxChar
*szString
, time_t WXUNUSED(t
))
406 (*m_ostr
) << wxConv_libc
.cWX2MB(szString
) << endl
<< flush
;
408 #endif // wxUSE_STD_IOSTREAM
412 // ----------------------------------------------------------------------------
413 // wxLogTextCtrl implementation
414 // ----------------------------------------------------------------------------
416 #if wxUSE_STD_IOSTREAM
417 wxLogTextCtrl::wxLogTextCtrl(wxTextCtrl
*pTextCtrl
)
418 #if !defined(NO_TEXT_WINDOW_STREAM)
419 : wxLogStream(new ostream(pTextCtrl
))
424 wxLogTextCtrl::~wxLogTextCtrl()
428 #endif // wxUSE_STD_IOSTREAM
430 // ----------------------------------------------------------------------------
431 // wxLogGui implementation (FIXME MT-unsafe)
432 // ----------------------------------------------------------------------------
439 void wxLogGui::Clear()
441 m_bErrors
= m_bWarnings
= FALSE
;
446 void wxLogGui::Flush()
448 if ( !m_bHasMessages
)
451 // do it right now to block any new calls to Flush() while we're here
452 m_bHasMessages
= FALSE
;
454 // concatenate all strings (but not too many to not overfill the msg box)
457 nMsgCount
= m_aMessages
.Count();
459 // start from the most recent message
460 for ( size_t n
= nMsgCount
; n
> 0; n
-- ) {
461 // for Windows strings longer than this value are wrapped (NT 4.0)
462 const size_t nMsgLineWidth
= 156;
464 nLines
+= (m_aMessages
[n
- 1].Len() + nMsgLineWidth
- 1) / nMsgLineWidth
;
466 if ( nLines
> 25 ) // don't put too many lines in message box
469 str
<< m_aMessages
[n
- 1] << _T("\n");
479 else if ( m_bWarnings
) {
480 title
= _("Warning");
481 style
= wxICON_EXCLAMATION
;
484 title
= _("Information");
485 style
= wxICON_INFORMATION
;
488 wxMessageBox(str
, title
, wxOK
| style
);
490 // no undisplayed messages whatsoever
494 // the default behaviour is to discard all informational messages if there
495 // are any errors/warnings.
496 void wxLogGui::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
503 m_aMessages
.Add(szString
);
504 m_aTimes
.Add((long)t
);
505 m_bHasMessages
= TRUE
;
512 // find the top window and set it's status text if it has any
513 wxFrame
*pFrame
= gs_pFrame
;
514 if ( pFrame
== NULL
) {
515 wxWindow
*pWin
= wxTheApp
->GetTopWindow();
516 if ( pWin
!= NULL
&& pWin
->IsKindOf(CLASSINFO(wxFrame
)) ) {
517 pFrame
= (wxFrame
*)pWin
;
521 if ( pFrame
!= NULL
)
522 pFrame
->SetStatusText(szString
);
524 #endif // wxUSE_STATUSBAR
532 // don't prepend debug/trace here: it goes to the
533 // debug window anyhow, but do put a timestamp
534 OutputDebugString(wxString(szString
) + _T("\n\r"));
536 // send them to stderr
537 wxFprintf(stderr
, _T("%s: %s\n"),
538 level
== wxLOG_Trace
? _T("Trace") : _T("Debug"),
543 #endif // __WXDEBUG__
547 case wxLOG_FatalError
:
548 // show this one immediately
549 wxMessageBox(szString
, _("Fatal error"), wxICON_HAND
);
553 // discard earlier informational messages if this is the 1st
554 // error because they might not make sense any more
558 m_bHasMessages
= TRUE
;
565 // for the warning we don't discard the info messages
569 m_aMessages
.Add(szString
);
570 m_aTimes
.Add((long)t
);
575 // ----------------------------------------------------------------------------
576 // wxLogWindow and wxLogFrame implementation
577 // ----------------------------------------------------------------------------
581 class wxLogFrame
: public wxFrame
585 wxLogFrame(wxFrame
*pParent
, wxLogWindow
*log
, const wxChar
*szTitle
);
586 virtual ~wxLogFrame();
589 void OnClose(wxCommandEvent
& event
);
590 void OnCloseWindow(wxCloseEvent
& event
);
592 void OnSave (wxCommandEvent
& event
);
594 void OnClear(wxCommandEvent
& event
);
596 void OnIdle(wxIdleEvent
&);
599 wxTextCtrl
*TextCtrl() const { return m_pTextCtrl
; }
609 // instead of closing just hide the window to be able to Show() it later
610 void DoClose() { Show(FALSE
); }
612 wxTextCtrl
*m_pTextCtrl
;
615 DECLARE_EVENT_TABLE()
618 BEGIN_EVENT_TABLE(wxLogFrame
, wxFrame
)
619 // wxLogWindow menu events
620 EVT_MENU(Menu_Close
, wxLogFrame::OnClose
)
622 EVT_MENU(Menu_Save
, wxLogFrame::OnSave
)
624 EVT_MENU(Menu_Clear
, wxLogFrame::OnClear
)
626 EVT_CLOSE(wxLogFrame::OnCloseWindow
)
629 wxLogFrame::wxLogFrame(wxFrame
*pParent
, wxLogWindow
*log
, const wxChar
*szTitle
)
630 : wxFrame(pParent
, -1, szTitle
)
634 m_pTextCtrl
= new wxTextCtrl(this, -1, wxEmptyString
, wxDefaultPosition
,
641 wxMenuBar
*pMenuBar
= new wxMenuBar
;
642 wxMenu
*pMenu
= new wxMenu
;
644 pMenu
->Append(Menu_Save
, _("&Save..."), _("Save log contents to file"));
646 pMenu
->Append(Menu_Clear
, _("C&lear"), _("Clear the log contents"));
647 pMenu
->AppendSeparator();
648 pMenu
->Append(Menu_Close
, _("&Close"), _("Close this window"));
649 pMenuBar
->Append(pMenu
, _("&Log"));
650 SetMenuBar(pMenuBar
);
653 // status bar for menu prompts
655 #endif // wxUSE_STATUSBAR
657 m_log
->OnFrameCreate(this);
660 void wxLogFrame::OnClose(wxCommandEvent
& WXUNUSED(event
))
665 void wxLogFrame::OnCloseWindow(wxCloseEvent
& WXUNUSED(event
))
671 void wxLogFrame::OnSave(wxCommandEvent
& WXUNUSED(event
))
675 const wxChar
*szFileName
= wxSaveFileSelector(_T("log"), _T("txt"), _T("log.txt"));
676 if ( szFileName
== NULL
) {
685 if ( wxFile::Exists(szFileName
) ) {
686 bool bAppend
= FALSE
;
688 strMsg
.Printf(_("Append log to file '%s' "
689 "(choosing [No] will overwrite it)?"), szFileName
);
690 switch ( wxMessageBox(strMsg
, _("Question"), wxYES_NO
| wxCANCEL
) ) {
703 wxFAIL_MSG(_("invalid message box return value"));
707 bOk
= file
.Open(szFileName
, wxFile::write_append
);
710 bOk
= file
.Create(szFileName
, TRUE
/* overwrite */);
714 bOk
= file
.Create(szFileName
);
717 // retrieve text and save it
718 // -------------------------
719 int nLines
= m_pTextCtrl
->GetNumberOfLines();
720 for ( int nLine
= 0; bOk
&& nLine
< nLines
; nLine
++ ) {
721 bOk
= file
.Write(m_pTextCtrl
->GetLineText(nLine
) +
722 // we're not going to pull in the whole wxTextFile if all we need is this...
725 #else // !wxUSE_TEXTFILE
727 #endif // wxUSE_TEXTFILE
735 wxLogError(_("Can't save log contents to file."));
738 wxLogStatus(this, _("Log saved to the file '%s'."), szFileName
);
743 void wxLogFrame::OnClear(wxCommandEvent
& WXUNUSED(event
))
745 m_pTextCtrl
->Clear();
748 wxLogFrame::~wxLogFrame()
750 m_log
->OnFrameDelete(this);
755 wxLogWindow::wxLogWindow(wxFrame
*pParent
,
756 const wxChar
*szTitle
,
760 m_bPassMessages
= bDoPass
;
762 m_pLogFrame
= new wxLogFrame(pParent
, this, szTitle
);
763 m_pOldLog
= wxLog::SetActiveTarget(this);
766 m_pLogFrame
->Show(TRUE
);
769 void wxLogWindow::Show(bool bShow
)
771 m_pLogFrame
->Show(bShow
);
774 void wxLogWindow::Flush()
776 if ( m_pOldLog
!= NULL
)
779 m_bHasMessages
= FALSE
;
782 void wxLogWindow::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
784 // first let the previous logger show it
785 if ( m_pOldLog
!= NULL
&& m_bPassMessages
) {
786 // FIXME why can't we access protected wxLog method from here (we derive
787 // from wxLog)? gcc gives "DoLog is protected in this context", what
788 // does this mean? Anyhow, the cast is harmless and let's us do what
790 ((wxLogWindow
*)m_pOldLog
)->DoLog(level
, szString
, t
);
796 // by default, these messages are ignored by wxLog, so process
798 if ( !wxIsEmpty(szString
) )
801 str
<< _("Status: ") << szString
;
806 // don't put trace messages in the text window for 2 reasons:
807 // 1) there are too many of them
808 // 2) they may provoke other trace messages thus sending a program
809 // into an infinite loop
814 // and this will format it nicely and call our DoLogString()
815 wxLog::DoLog(level
, szString
, t
);
819 m_bHasMessages
= TRUE
;
822 void wxLogWindow::DoLogString(const wxChar
*szString
, time_t WXUNUSED(t
))
824 // put the text into our window
825 wxTextCtrl
*pText
= m_pLogFrame
->TextCtrl();
827 // remove selection (WriteText is in fact ReplaceSelection)
829 long nLen
= pText
->GetLastPosition();
830 pText
->SetSelection(nLen
, nLen
);
833 pText
->WriteText(szString
);
834 pText
->WriteText(_T("\n")); // "\n" ok here (_not_ "\r\n")
836 // TODO ensure that the line can be seen
839 wxFrame
*wxLogWindow::GetFrame() const
844 void wxLogWindow::OnFrameCreate(wxFrame
* WXUNUSED(frame
))
848 void wxLogWindow::OnFrameDelete(wxFrame
* WXUNUSED(frame
))
850 m_pLogFrame
= (wxLogFrame
*)NULL
;
853 wxLogWindow::~wxLogWindow()
857 // may be NULL if log frame already auto destroyed itself
863 // ============================================================================
864 // Global functions/variables
865 // ============================================================================
867 // ----------------------------------------------------------------------------
869 // ----------------------------------------------------------------------------
871 wxLog
*wxLog::ms_pLogger
= (wxLog
*)NULL
;
872 bool wxLog::ms_doLog
= TRUE
;
873 bool wxLog::ms_bAutoCreate
= TRUE
;
874 wxTraceMask
wxLog::ms_ulTraceMask
= (wxTraceMask
)0;
875 wxArrayString
wxLog::ms_aTraceMasks
;
877 // ----------------------------------------------------------------------------
878 // stdout error logging helper
879 // ----------------------------------------------------------------------------
881 // helper function: wraps the message and justifies it under given position
882 // (looks more pretty on the terminal). Also adds newline at the end.
884 // TODO this is now disabled until I find a portable way of determining the
885 // terminal window size (ok, I found it but does anybody really cares?)
886 #ifdef LOG_PRETTY_WRAP
887 static void wxLogWrap(FILE *f
, const char *pszPrefix
, const char *psz
)
889 size_t nMax
= 80; // FIXME
890 size_t nStart
= strlen(pszPrefix
);
894 while ( *psz
!= '\0' ) {
895 for ( n
= nStart
; (n
< nMax
) && (*psz
!= '\0'); n
++ )
899 if ( *psz
!= '\0' ) {
901 for ( n
= 0; n
< nStart
; n
++ )
904 // as we wrapped, squeeze all white space
905 while ( isspace(*psz
) )
912 #endif //LOG_PRETTY_WRAP
914 // ----------------------------------------------------------------------------
915 // error code/error message retrieval functions
916 // ----------------------------------------------------------------------------
918 // get error code from syste
919 unsigned long wxSysErrorCode()
923 return ::GetLastError();
925 // TODO what to do on Windows 3.1?
933 // get error message from system
934 const wxChar
*wxSysErrorMsg(unsigned long nErrCode
)
937 nErrCode
= wxSysErrorCode();
941 static wxChar s_szBuf
[LOG_BUFFER_SIZE
/ 2];
943 // get error message from system
945 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
,
947 MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
),
951 // copy it to our buffer and free memory
952 wxStrncpy(s_szBuf
, (const wxChar
*)lpMsgBuf
, WXSIZEOF(s_szBuf
) - 1);
953 s_szBuf
[WXSIZEOF(s_szBuf
) - 1] = _T('\0');
956 // returned string is capitalized and ended with '\r\n' - bad
957 s_szBuf
[0] = (wxChar
)wxTolower(s_szBuf
[0]);
958 size_t len
= wxStrlen(s_szBuf
);
961 if ( s_szBuf
[len
- 2] == _T('\r') )
962 s_szBuf
[len
- 2] = _T('\0');
972 static wxChar s_szBuf
[LOG_BUFFER_SIZE
/ 2];
973 wxConv_libc
.MB2WC(s_szBuf
, strerror(nErrCode
), WXSIZEOF(s_szBuf
) -1);
976 return strerror(nErrCode
);
981 // ----------------------------------------------------------------------------
983 // ----------------------------------------------------------------------------
987 // break into the debugger
992 #elif defined(__WXMAC__)
998 #elif defined(__UNIX__)
1005 // this function is called when an assert fails
1006 void wxOnAssert(const wxChar
*szFile
, int nLine
, const wxChar
*szMsg
)
1008 // this variable can be set to true to suppress "assert failure" messages
1009 static bool s_bNoAsserts
= FALSE
;
1010 static bool s_bInAssert
= FALSE
; // FIXME MT-unsafe
1012 if ( s_bInAssert
) {
1013 // He-e-e-e-elp!! we're trapped in endless loop
1016 s_bInAssert
= FALSE
;
1023 wxChar szBuf
[LOG_BUFFER_SIZE
];
1025 // make life easier for people using VC++ IDE: clicking on the message
1026 // will take us immediately to the place of the failed assert
1028 wxSprintf(szBuf
, _T("%s(%d): assert failed"), szFile
, nLine
);
1030 // make the error message more clear for all the others
1031 wxSprintf(szBuf
, _T("Assert failed in file %s at line %d"), szFile
, nLine
);
1034 if ( szMsg
!= NULL
) {
1035 wxStrcat(szBuf
, _T(": "));
1036 wxStrcat(szBuf
, szMsg
);
1039 wxStrcat(szBuf
, _T("."));
1042 if ( !s_bNoAsserts
) {
1043 // send it to the normal log destination
1049 // this message is intentionally not translated - it is for
1051 wxStrcat(szBuf
, _T("\nDo you want to stop the program?"
1052 "\nYou can also choose [Cancel] to suppress "
1053 "further warnings."));
1055 switch ( wxMessageBox(szBuf
, _("Debug"),
1056 wxYES_NO
| wxCANCEL
| wxICON_STOP
) ) {
1062 s_bNoAsserts
= TRUE
;
1065 //case wxNO: nothing to do
1070 s_bInAssert
= FALSE
;