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"
34 #include "wx/msw/private.h"
38 #include "wx/string.h"
42 #include "wx/msgdlg.h"
43 #include "wx/filedlg.h"
44 #include "wx/textctrl.h"
48 #include "wx/textfile.h"
52 // other standard headers
59 // Redefines OutputDebugString if necessary
60 #include "wx/msw/private.h"
65 // ----------------------------------------------------------------------------
66 // non member functions
67 // ----------------------------------------------------------------------------
69 // define this to enable wrapping of log messages
70 //#define LOG_PRETTY_WRAP
72 #ifdef LOG_PRETTY_WRAP
73 static void wxLogWrap(FILE *f
, const char *pszPrefix
, const char *psz
);
76 // ----------------------------------------------------------------------------
78 // ----------------------------------------------------------------------------
80 // we use a global variable to store the frame pointer for wxLogStatus - bad,
81 // but it's he easiest way
82 static wxFrame
*gs_pFrame
; // FIXME MT-unsafe
84 // ============================================================================
86 // ============================================================================
88 // ----------------------------------------------------------------------------
89 // implementation of Log functions
91 // NB: unfortunately we need all these distinct functions, we can't make them
92 // macros and not all compilers inline vararg functions.
93 // ----------------------------------------------------------------------------
95 // log functions can't allocate memory (LogError("out of memory...") should
96 // work!), so we use a static buffer for all log messages
97 #define LOG_BUFFER_SIZE (4096)
99 // static buffer for error messages (FIXME MT-unsafe)
100 static wxChar s_szBuf
[LOG_BUFFER_SIZE
];
102 // generic log function
103 void wxLogGeneric(wxLogLevel level
, const wxChar
*szFormat
, ...)
105 if ( wxLog::GetActiveTarget() != NULL
) {
107 va_start(argptr
, szFormat
);
108 wxVsprintf(s_szBuf
, szFormat
, argptr
);
111 wxLog::OnLog(level
, s_szBuf
, time(NULL
));
115 #define IMPLEMENT_LOG_FUNCTION(level) \
116 void wxLog##level(const wxChar *szFormat, ...) \
118 if ( wxLog::GetActiveTarget() != NULL ) { \
120 va_start(argptr, szFormat); \
121 wxVsprintf(s_szBuf, szFormat, argptr); \
124 wxLog::OnLog(wxLOG_##level, s_szBuf, time(NULL)); \
128 IMPLEMENT_LOG_FUNCTION(FatalError
)
129 IMPLEMENT_LOG_FUNCTION(Error
)
130 IMPLEMENT_LOG_FUNCTION(Warning
)
131 IMPLEMENT_LOG_FUNCTION(Message
)
132 IMPLEMENT_LOG_FUNCTION(Info
)
133 IMPLEMENT_LOG_FUNCTION(Status
)
135 // accepts an additional argument which tells to which frame the output should
137 void wxLogStatus(wxFrame
*pFrame
, const wxChar
*szFormat
, ...)
139 wxLog
*pLog
= wxLog::GetActiveTarget();
140 if ( pLog
!= NULL
) {
142 va_start(argptr
, szFormat
);
143 wxVsprintf(s_szBuf
, szFormat
, argptr
);
146 wxASSERT( gs_pFrame
== NULL
); // should be reset!
148 wxLog::OnLog(wxLOG_Status
, s_szBuf
, time(NULL
));
149 gs_pFrame
= (wxFrame
*) NULL
;
153 // same as info, but only if 'verbose' mode is on
154 void wxLogVerbose(const wxChar
*szFormat
, ...)
156 wxLog
*pLog
= wxLog::GetActiveTarget();
157 if ( pLog
!= NULL
&& pLog
->GetVerbose() ) {
159 va_start(argptr
, szFormat
);
160 wxVsprintf(s_szBuf
, szFormat
, argptr
);
163 wxLog::OnLog(wxLOG_Info
, s_szBuf
, time(NULL
));
169 #define IMPLEMENT_LOG_DEBUG_FUNCTION(level) \
170 void wxLog##level(const wxChar *szFormat, ...) \
172 if ( wxLog::GetActiveTarget() != NULL ) { \
174 va_start(argptr, szFormat); \
175 wxVsprintf(s_szBuf, szFormat, argptr); \
178 wxLog::OnLog(wxLOG_##level, s_szBuf, time(NULL)); \
182 void wxLogTrace(const wxChar
*mask
, const wxChar
*szFormat
, ...)
184 wxLog
*pLog
= wxLog::GetActiveTarget();
186 if ( pLog
!= NULL
&& wxLog::IsAllowedTraceMask(mask
) ) {
188 va_start(argptr
, szFormat
);
189 wxVsprintf(s_szBuf
, szFormat
, argptr
);
192 wxLog::OnLog(wxLOG_Trace
, s_szBuf
, time(NULL
));
196 void wxLogTrace(wxTraceMask mask
, const wxChar
*szFormat
, ...)
198 wxLog
*pLog
= wxLog::GetActiveTarget();
200 // we check that all of mask bits are set in the current mask, so
201 // that wxLogTrace(wxTraceRefCount | wxTraceOle) will only do something
202 // if both bits are set.
203 if ( pLog
!= NULL
&& ((pLog
->GetTraceMask() & mask
) == mask
) ) {
205 va_start(argptr
, szFormat
);
206 wxVsprintf(s_szBuf
, szFormat
, argptr
);
209 wxLog::OnLog(wxLOG_Trace
, s_szBuf
, time(NULL
));
214 #define IMPLEMENT_LOG_DEBUG_FUNCTION(level)
217 IMPLEMENT_LOG_DEBUG_FUNCTION(Debug
)
218 IMPLEMENT_LOG_DEBUG_FUNCTION(Trace
)
220 // wxLogSysError: one uses the last error code, for other you must give it
223 // common part of both wxLogSysError
224 void wxLogSysErrorHelper(long lErrCode
)
226 wxChar szErrMsg
[LOG_BUFFER_SIZE
/ 2];
227 wxSprintf(szErrMsg
, _(" (error %ld: %s)"), lErrCode
, wxSysErrorMsg(lErrCode
));
228 wxStrncat(s_szBuf
, szErrMsg
, WXSIZEOF(s_szBuf
) - wxStrlen(s_szBuf
));
230 wxLog::OnLog(wxLOG_Error
, s_szBuf
, time(NULL
));
233 void WXDLLEXPORT
wxLogSysError(const wxChar
*szFormat
, ...)
236 va_start(argptr
, szFormat
);
237 wxVsprintf(s_szBuf
, szFormat
, argptr
);
240 wxLogSysErrorHelper(wxSysErrorCode());
243 void WXDLLEXPORT
wxLogSysError(long lErrCode
, const wxChar
*szFormat
, ...)
246 va_start(argptr
, szFormat
);
247 wxVsprintf(s_szBuf
, szFormat
, argptr
);
250 wxLogSysErrorHelper(lErrCode
);
253 // ----------------------------------------------------------------------------
254 // wxLog class implementation
255 // ----------------------------------------------------------------------------
259 m_bHasMessages
= FALSE
;
261 // enable verbose messages by default in the debug builds
266 #endif // debug/release
269 wxLog
*wxLog::GetActiveTarget()
271 if ( ms_bAutoCreate
&& ms_pLogger
== NULL
) {
272 // prevent infinite recursion if someone calls wxLogXXX() from
273 // wxApp::CreateLogTarget()
274 static bool s_bInGetActiveTarget
= FALSE
;
275 if ( !s_bInGetActiveTarget
) {
276 s_bInGetActiveTarget
= TRUE
;
279 ms_pLogger
= new wxLogStderr
;
281 // ask the application to create a log target for us
282 if ( wxTheApp
!= NULL
)
283 ms_pLogger
= wxTheApp
->CreateLogTarget();
285 ms_pLogger
= new wxLogStderr
;
288 s_bInGetActiveTarget
= FALSE
;
290 // do nothing if it fails - what can we do?
297 wxLog
*wxLog::SetActiveTarget(wxLog
*pLogger
)
299 if ( ms_pLogger
!= NULL
) {
300 // flush the old messages before changing because otherwise they might
301 // get lost later if this target is not restored
305 wxLog
*pOldLogger
= ms_pLogger
;
306 ms_pLogger
= pLogger
;
311 void wxLog::RemoveTraceMask(const wxString
& str
)
313 int index
= ms_aTraceMasks
.Index(str
);
314 if ( index
!= wxNOT_FOUND
)
315 ms_aTraceMasks
.Remove((size_t)index
);
318 void wxLog::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
321 case wxLOG_FatalError
:
322 DoLogString(wxString(_("Fatal error: ")) + szString
, t
);
323 DoLogString(_("Program aborted."), t
);
329 DoLogString(wxString(_("Error: ")) + szString
, t
);
333 DoLogString(wxString(_("Warning: ")) + szString
, t
);
339 default: // log unknown log levels too
340 DoLogString(szString
, t
);
350 DoLogString(szString
, t
);
356 void wxLog::DoLogString(const wxChar
*WXUNUSED(szString
), time_t WXUNUSED(t
))
358 wxFAIL_MSG(_T("DoLogString must be overriden if it's called."));
366 // ----------------------------------------------------------------------------
367 // wxLogStderr class implementation
368 // ----------------------------------------------------------------------------
370 wxLogStderr::wxLogStderr(FILE *fp
)
378 void wxLogStderr::DoLogString(const wxChar
*szString
, time_t WXUNUSED(t
))
380 wxString
str(szString
);
383 fputs(str
.mb_str(), m_fp
);
386 // under Windows, programs usually don't have stderr at all, so make show the
387 // messages also under debugger
389 OutputDebugString(str
+ _T('\r'));
393 // ----------------------------------------------------------------------------
394 // wxLogStream implementation
395 // ----------------------------------------------------------------------------
397 #if wxUSE_STD_IOSTREAM
398 wxLogStream::wxLogStream(ostream
*ostr
)
406 void wxLogStream::DoLogString(const wxChar
*szString
, time_t WXUNUSED(t
))
408 (*m_ostr
) << wxConv_libc
.cWX2MB(szString
) << endl
<< flush
;
410 #endif // wxUSE_STD_IOSTREAM
414 // ----------------------------------------------------------------------------
415 // wxLogTextCtrl implementation
416 // ----------------------------------------------------------------------------
418 #if wxUSE_STD_IOSTREAM
419 wxLogTextCtrl::wxLogTextCtrl(wxTextCtrl
*pTextCtrl
)
420 #if !defined(NO_TEXT_WINDOW_STREAM)
421 : wxLogStream(new ostream(pTextCtrl
))
426 wxLogTextCtrl::~wxLogTextCtrl()
430 #endif // wxUSE_STD_IOSTREAM
432 // ----------------------------------------------------------------------------
433 // wxLogGui implementation (FIXME MT-unsafe)
434 // ----------------------------------------------------------------------------
441 void wxLogGui::Clear()
443 m_bErrors
= m_bWarnings
= FALSE
;
448 void wxLogGui::Flush()
450 if ( !m_bHasMessages
)
453 // do it right now to block any new calls to Flush() while we're here
454 m_bHasMessages
= FALSE
;
456 // concatenate all strings (but not too many to not overfill the msg box)
459 nMsgCount
= m_aMessages
.Count();
461 // start from the most recent message
462 for ( size_t n
= nMsgCount
; n
> 0; n
-- ) {
463 // for Windows strings longer than this value are wrapped (NT 4.0)
464 const size_t nMsgLineWidth
= 156;
466 nLines
+= (m_aMessages
[n
- 1].Len() + nMsgLineWidth
- 1) / nMsgLineWidth
;
468 if ( nLines
> 25 ) // don't put too many lines in message box
471 str
<< m_aMessages
[n
- 1] << _T("\n");
481 else if ( m_bWarnings
) {
482 title
= _("Warning");
483 style
= wxICON_EXCLAMATION
;
486 title
= _("Information");
487 style
= wxICON_INFORMATION
;
490 wxMessageBox(str
, title
, wxOK
| style
);
492 // no undisplayed messages whatsoever
496 // the default behaviour is to discard all informational messages if there
497 // are any errors/warnings.
498 void wxLogGui::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
505 m_aMessages
.Add(szString
);
506 m_aTimes
.Add((long)t
);
507 m_bHasMessages
= TRUE
;
514 // find the top window and set it's status text if it has any
515 wxFrame
*pFrame
= gs_pFrame
;
516 if ( pFrame
== NULL
) {
517 wxWindow
*pWin
= wxTheApp
->GetTopWindow();
518 if ( pWin
!= NULL
&& pWin
->IsKindOf(CLASSINFO(wxFrame
)) ) {
519 pFrame
= (wxFrame
*)pWin
;
523 if ( pFrame
!= NULL
)
524 pFrame
->SetStatusText(szString
);
526 #endif // wxUSE_STATUSBAR
534 // don't prepend debug/trace here: it goes to the
535 // debug window anyhow, but do put a timestamp
536 OutputDebugString(wxString(szString
) + _T("\n\r"));
538 // send them to stderr
539 wxFprintf(stderr
, _T("%s: %s\n"),
540 level
== wxLOG_Trace
? _T("Trace") : _T("Debug"),
545 #endif // __WXDEBUG__
549 case wxLOG_FatalError
:
550 // show this one immediately
551 wxMessageBox(szString
, _("Fatal error"), wxICON_HAND
);
555 // discard earlier informational messages if this is the 1st
556 // error because they might not make sense any more
560 m_bHasMessages
= TRUE
;
567 // for the warning we don't discard the info messages
571 m_aMessages
.Add(szString
);
572 m_aTimes
.Add((long)t
);
577 // ----------------------------------------------------------------------------
578 // wxLogWindow and wxLogFrame implementation
579 // ----------------------------------------------------------------------------
583 class wxLogFrame
: public wxFrame
587 wxLogFrame(wxFrame
*pParent
, wxLogWindow
*log
, const wxChar
*szTitle
);
588 virtual ~wxLogFrame();
591 void OnClose(wxCommandEvent
& event
);
592 void OnCloseWindow(wxCloseEvent
& event
);
594 void OnSave (wxCommandEvent
& event
);
596 void OnClear(wxCommandEvent
& event
);
598 void OnIdle(wxIdleEvent
&);
601 wxTextCtrl
*TextCtrl() const { return m_pTextCtrl
; }
611 // instead of closing just hide the window to be able to Show() it later
612 void DoClose() { Show(FALSE
); }
614 wxTextCtrl
*m_pTextCtrl
;
617 DECLARE_EVENT_TABLE()
620 BEGIN_EVENT_TABLE(wxLogFrame
, wxFrame
)
621 // wxLogWindow menu events
622 EVT_MENU(Menu_Close
, wxLogFrame::OnClose
)
624 EVT_MENU(Menu_Save
, wxLogFrame::OnSave
)
626 EVT_MENU(Menu_Clear
, wxLogFrame::OnClear
)
628 EVT_CLOSE(wxLogFrame::OnCloseWindow
)
631 wxLogFrame::wxLogFrame(wxFrame
*pParent
, wxLogWindow
*log
, const wxChar
*szTitle
)
632 : wxFrame(pParent
, -1, szTitle
)
636 m_pTextCtrl
= new wxTextCtrl(this, -1, wxEmptyString
, wxDefaultPosition
,
643 wxMenuBar
*pMenuBar
= new wxMenuBar
;
644 wxMenu
*pMenu
= new wxMenu
;
646 pMenu
->Append(Menu_Save
, _("&Save..."), _("Save log contents to file"));
648 pMenu
->Append(Menu_Clear
, _("C&lear"), _("Clear the log contents"));
649 pMenu
->AppendSeparator();
650 pMenu
->Append(Menu_Close
, _("&Close"), _("Close this window"));
651 pMenuBar
->Append(pMenu
, _("&Log"));
652 SetMenuBar(pMenuBar
);
655 // status bar for menu prompts
657 #endif // wxUSE_STATUSBAR
659 m_log
->OnFrameCreate(this);
662 void wxLogFrame::OnClose(wxCommandEvent
& WXUNUSED(event
))
667 void wxLogFrame::OnCloseWindow(wxCloseEvent
& WXUNUSED(event
))
673 void wxLogFrame::OnSave(wxCommandEvent
& WXUNUSED(event
))
677 const wxChar
*szFileName
= wxSaveFileSelector(_T("log"), _T("txt"), _T("log.txt"));
678 if ( szFileName
== NULL
) {
687 if ( wxFile::Exists(szFileName
) ) {
688 bool bAppend
= FALSE
;
690 strMsg
.Printf(_("Append log to file '%s' "
691 "(choosing [No] will overwrite it)?"), szFileName
);
692 switch ( wxMessageBox(strMsg
, _("Question"), wxYES_NO
| wxCANCEL
) ) {
705 wxFAIL_MSG(_("invalid message box return value"));
709 bOk
= file
.Open(szFileName
, wxFile::write_append
);
712 bOk
= file
.Create(szFileName
, TRUE
/* overwrite */);
716 bOk
= file
.Create(szFileName
);
719 // retrieve text and save it
720 // -------------------------
721 int nLines
= m_pTextCtrl
->GetNumberOfLines();
722 for ( int nLine
= 0; bOk
&& nLine
< nLines
; nLine
++ ) {
723 bOk
= file
.Write(m_pTextCtrl
->GetLineText(nLine
) +
724 // we're not going to pull in the whole wxTextFile if all we need is this...
727 #else // !wxUSE_TEXTFILE
729 #endif // wxUSE_TEXTFILE
737 wxLogError(_("Can't save log contents to file."));
740 wxLogStatus(this, _("Log saved to the file '%s'."), szFileName
);
745 void wxLogFrame::OnClear(wxCommandEvent
& WXUNUSED(event
))
747 m_pTextCtrl
->Clear();
750 wxLogFrame::~wxLogFrame()
752 m_log
->OnFrameDelete(this);
757 wxLogWindow::wxLogWindow(wxFrame
*pParent
,
758 const wxChar
*szTitle
,
762 m_bPassMessages
= bDoPass
;
764 m_pLogFrame
= new wxLogFrame(pParent
, this, szTitle
);
765 m_pOldLog
= wxLog::SetActiveTarget(this);
768 m_pLogFrame
->Show(TRUE
);
771 void wxLogWindow::Show(bool bShow
)
773 m_pLogFrame
->Show(bShow
);
776 void wxLogWindow::Flush()
778 if ( m_pOldLog
!= NULL
)
781 m_bHasMessages
= FALSE
;
784 void wxLogWindow::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
786 // first let the previous logger show it
787 if ( m_pOldLog
!= NULL
&& m_bPassMessages
) {
788 // FIXME why can't we access protected wxLog method from here (we derive
789 // from wxLog)? gcc gives "DoLog is protected in this context", what
790 // does this mean? Anyhow, the cast is harmless and let's us do what
792 ((wxLogWindow
*)m_pOldLog
)->DoLog(level
, szString
, t
);
798 // by default, these messages are ignored by wxLog, so process
800 if ( !wxIsEmpty(szString
) )
803 str
<< _("Status: ") << szString
;
808 // don't put trace messages in the text window for 2 reasons:
809 // 1) there are too many of them
810 // 2) they may provoke other trace messages thus sending a program
811 // into an infinite loop
816 // and this will format it nicely and call our DoLogString()
817 wxLog::DoLog(level
, szString
, t
);
821 m_bHasMessages
= TRUE
;
824 void wxLogWindow::DoLogString(const wxChar
*szString
, time_t WXUNUSED(t
))
826 // put the text into our window
827 wxTextCtrl
*pText
= m_pLogFrame
->TextCtrl();
829 // remove selection (WriteText is in fact ReplaceSelection)
831 long nLen
= pText
->GetLastPosition();
832 pText
->SetSelection(nLen
, nLen
);
835 pText
->WriteText(szString
);
836 pText
->WriteText(_T("\n")); // "\n" ok here (_not_ "\r\n")
838 // TODO ensure that the line can be seen
841 wxFrame
*wxLogWindow::GetFrame() const
846 void wxLogWindow::OnFrameCreate(wxFrame
* WXUNUSED(frame
))
850 void wxLogWindow::OnFrameDelete(wxFrame
* WXUNUSED(frame
))
852 m_pLogFrame
= (wxLogFrame
*)NULL
;
855 wxLogWindow::~wxLogWindow()
859 // may be NULL if log frame already auto destroyed itself
865 // ============================================================================
866 // Global functions/variables
867 // ============================================================================
869 // ----------------------------------------------------------------------------
871 // ----------------------------------------------------------------------------
873 wxLog
*wxLog::ms_pLogger
= (wxLog
*)NULL
;
874 bool wxLog::ms_doLog
= TRUE
;
875 bool wxLog::ms_bAutoCreate
= TRUE
;
876 wxTraceMask
wxLog::ms_ulTraceMask
= (wxTraceMask
)0;
877 wxArrayString
wxLog::ms_aTraceMasks
;
879 // ----------------------------------------------------------------------------
880 // stdout error logging helper
881 // ----------------------------------------------------------------------------
883 // helper function: wraps the message and justifies it under given position
884 // (looks more pretty on the terminal). Also adds newline at the end.
886 // TODO this is now disabled until I find a portable way of determining the
887 // terminal window size (ok, I found it but does anybody really cares?)
888 #ifdef LOG_PRETTY_WRAP
889 static void wxLogWrap(FILE *f
, const char *pszPrefix
, const char *psz
)
891 size_t nMax
= 80; // FIXME
892 size_t nStart
= strlen(pszPrefix
);
896 while ( *psz
!= '\0' ) {
897 for ( n
= nStart
; (n
< nMax
) && (*psz
!= '\0'); n
++ )
901 if ( *psz
!= '\0' ) {
903 for ( n
= 0; n
< nStart
; n
++ )
906 // as we wrapped, squeeze all white space
907 while ( isspace(*psz
) )
914 #endif //LOG_PRETTY_WRAP
916 // ----------------------------------------------------------------------------
917 // error code/error message retrieval functions
918 // ----------------------------------------------------------------------------
920 // get error code from syste
921 unsigned long wxSysErrorCode()
925 return ::GetLastError();
927 // TODO what to do on Windows 3.1?
935 // get error message from system
936 const wxChar
*wxSysErrorMsg(unsigned long nErrCode
)
939 nErrCode
= wxSysErrorCode();
943 static wxChar s_szBuf
[LOG_BUFFER_SIZE
/ 2];
945 // get error message from system
947 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
,
949 MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
),
953 // copy it to our buffer and free memory
954 wxStrncpy(s_szBuf
, (const wxChar
*)lpMsgBuf
, WXSIZEOF(s_szBuf
) - 1);
955 s_szBuf
[WXSIZEOF(s_szBuf
) - 1] = _T('\0');
958 // returned string is capitalized and ended with '\r\n' - bad
959 s_szBuf
[0] = (wxChar
)wxTolower(s_szBuf
[0]);
960 size_t len
= wxStrlen(s_szBuf
);
963 if ( s_szBuf
[len
- 2] == _T('\r') )
964 s_szBuf
[len
- 2] = _T('\0');
974 static wxChar s_szBuf
[LOG_BUFFER_SIZE
/ 2];
975 wxConv_libc
.MB2WC(s_szBuf
, strerror(nErrCode
), WXSIZEOF(s_szBuf
) -1);
978 return strerror(nErrCode
);
983 // ----------------------------------------------------------------------------
985 // ----------------------------------------------------------------------------
989 // break into the debugger
994 #elif defined(__WXMAC__)
1000 #elif defined(__UNIX__)
1007 // this function is called when an assert fails
1008 void wxOnAssert(const wxChar
*szFile
, int nLine
, const wxChar
*szMsg
)
1010 // this variable can be set to true to suppress "assert failure" messages
1011 static bool s_bNoAsserts
= FALSE
;
1012 static bool s_bInAssert
= FALSE
; // FIXME MT-unsafe
1014 if ( s_bInAssert
) {
1015 // He-e-e-e-elp!! we're trapped in endless loop
1018 s_bInAssert
= FALSE
;
1025 wxChar szBuf
[LOG_BUFFER_SIZE
];
1027 // make life easier for people using VC++ IDE: clicking on the message
1028 // will take us immediately to the place of the failed assert
1030 wxSprintf(szBuf
, _T("%s(%d): assert failed"), szFile
, nLine
);
1032 // make the error message more clear for all the others
1033 wxSprintf(szBuf
, _T("Assert failed in file %s at line %d"), szFile
, nLine
);
1036 if ( szMsg
!= NULL
) {
1037 wxStrcat(szBuf
, _T(": "));
1038 wxStrcat(szBuf
, szMsg
);
1041 wxStrcat(szBuf
, _T("."));
1044 if ( !s_bNoAsserts
) {
1045 // send it to the normal log destination
1051 // this message is intentionally not translated - it is for
1053 wxStrcat(szBuf
, _T("\nDo you want to stop the program?"
1054 "\nYou can also choose [Cancel] to suppress "
1055 "further warnings."));
1057 switch ( wxMessageBox(szBuf
, _("Debug"),
1058 wxYES_NO
| wxCANCEL
| wxICON_STOP
) ) {
1064 s_bNoAsserts
= TRUE
;
1067 //case wxNO: nothing to do
1072 s_bInAssert
= FALSE
;