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"
34 #include <wx/string.h>
38 #include <wx/msgdlg.h>
39 #include <wx/filedlg.h>
40 #include <wx/textctrl.h>
44 #include <wx/textfile.h>
48 // other standard headers
55 // Redefines OutputDebugString if necessary
56 #include "wx/msw/private.h"
61 // ----------------------------------------------------------------------------
62 // non member functions
63 // ----------------------------------------------------------------------------
65 // define this to enable wrapping of log messages
66 //#define LOG_PRETTY_WRAP
68 #ifdef LOG_PRETTY_WRAP
69 static void wxLogWrap(FILE *f
, const char *pszPrefix
, const char *psz
);
72 // ----------------------------------------------------------------------------
74 // ----------------------------------------------------------------------------
76 // we use a global variable to store the frame pointer for wxLogStatus - bad,
77 // but it's he easiest way
78 static wxFrame
*gs_pFrame
; // FIXME MT-unsafe
80 // ============================================================================
82 // ============================================================================
84 // ----------------------------------------------------------------------------
85 // implementation of Log functions
87 // NB: unfortunately we need all these distinct functions, we can't make them
88 // macros and not all compilers inline vararg functions.
89 // ----------------------------------------------------------------------------
91 // log functions can't allocate memory (LogError("out of memory...") should
92 // work!), so we use a static buffer for all log messages
93 #define LOG_BUFFER_SIZE (4096)
95 // static buffer for error messages (FIXME MT-unsafe)
96 static wxChar s_szBuf
[LOG_BUFFER_SIZE
];
98 // generic log function
99 void wxLogGeneric(wxLogLevel level
, const wxChar
*szFormat
, ...)
101 if ( wxLog::GetActiveTarget() != NULL
) {
103 va_start(argptr
, szFormat
);
104 wxVsprintf(s_szBuf
, szFormat
, argptr
);
107 wxLog::OnLog(level
, s_szBuf
, time(NULL
));
111 #define IMPLEMENT_LOG_FUNCTION(level) \
112 void wxLog##level(const wxChar *szFormat, ...) \
114 if ( wxLog::GetActiveTarget() != NULL ) { \
116 va_start(argptr, szFormat); \
117 wxVsprintf(s_szBuf, szFormat, argptr); \
120 wxLog::OnLog(wxLOG_##level, s_szBuf, time(NULL)); \
124 IMPLEMENT_LOG_FUNCTION(FatalError
)
125 IMPLEMENT_LOG_FUNCTION(Error
)
126 IMPLEMENT_LOG_FUNCTION(Warning
)
127 IMPLEMENT_LOG_FUNCTION(Message
)
128 IMPLEMENT_LOG_FUNCTION(Info
)
129 IMPLEMENT_LOG_FUNCTION(Status
)
131 // accepts an additional argument which tells to which frame the output should
133 void wxLogStatus(wxFrame
*pFrame
, const wxChar
*szFormat
, ...)
135 wxLog
*pLog
= wxLog::GetActiveTarget();
136 if ( pLog
!= NULL
) {
138 va_start(argptr
, szFormat
);
139 wxVsprintf(s_szBuf
, szFormat
, argptr
);
142 wxASSERT( gs_pFrame
== NULL
); // should be reset!
144 wxLog::OnLog(wxLOG_Status
, s_szBuf
, time(NULL
));
145 gs_pFrame
= (wxFrame
*) NULL
;
149 // same as info, but only if 'verbose' mode is on
150 void wxLogVerbose(const wxChar
*szFormat
, ...)
152 wxLog
*pLog
= wxLog::GetActiveTarget();
153 if ( pLog
!= NULL
&& pLog
->GetVerbose() ) {
155 va_start(argptr
, szFormat
);
156 wxVsprintf(s_szBuf
, szFormat
, argptr
);
159 wxLog::OnLog(wxLOG_Info
, s_szBuf
, time(NULL
));
165 #define IMPLEMENT_LOG_DEBUG_FUNCTION(level) \
166 void wxLog##level(const wxChar *szFormat, ...) \
168 if ( wxLog::GetActiveTarget() != NULL ) { \
170 va_start(argptr, szFormat); \
171 wxVsprintf(s_szBuf, szFormat, argptr); \
174 wxLog::OnLog(wxLOG_##level, s_szBuf, time(NULL)); \
178 void wxLogTrace(const wxChar
*mask
, const wxChar
*szFormat
, ...)
180 wxLog
*pLog
= wxLog::GetActiveTarget();
182 if ( pLog
!= NULL
&& wxLog::IsAllowedTraceMask(mask
) ) {
184 va_start(argptr
, szFormat
);
185 wxVsprintf(s_szBuf
, szFormat
, argptr
);
188 wxLog::OnLog(wxLOG_Trace
, s_szBuf
, time(NULL
));
192 void wxLogTrace(wxTraceMask mask
, const wxChar
*szFormat
, ...)
194 wxLog
*pLog
= wxLog::GetActiveTarget();
196 // we check that all of mask bits are set in the current mask, so
197 // that wxLogTrace(wxTraceRefCount | wxTraceOle) will only do something
198 // if both bits are set.
199 if ( pLog
!= NULL
&& ((pLog
->GetTraceMask() & mask
) == mask
) ) {
201 va_start(argptr
, szFormat
);
202 wxVsprintf(s_szBuf
, szFormat
, argptr
);
205 wxLog::OnLog(wxLOG_Trace
, s_szBuf
, time(NULL
));
210 #define IMPLEMENT_LOG_DEBUG_FUNCTION(level)
213 IMPLEMENT_LOG_DEBUG_FUNCTION(Debug
)
214 IMPLEMENT_LOG_DEBUG_FUNCTION(Trace
)
216 // wxLogSysError: one uses the last error code, for other you must give it
219 // common part of both wxLogSysError
220 void wxLogSysErrorHelper(long lErrCode
)
222 wxChar szErrMsg
[LOG_BUFFER_SIZE
/ 2];
223 wxSprintf(szErrMsg
, _(" (error %ld: %s)"), lErrCode
, wxSysErrorMsg(lErrCode
));
224 wxStrncat(s_szBuf
, szErrMsg
, WXSIZEOF(s_szBuf
) - wxStrlen(s_szBuf
));
226 wxLog::OnLog(wxLOG_Error
, s_szBuf
, time(NULL
));
229 void WXDLLEXPORT
wxLogSysError(const wxChar
*szFormat
, ...)
232 va_start(argptr
, szFormat
);
233 wxVsprintf(s_szBuf
, szFormat
, argptr
);
236 wxLogSysErrorHelper(wxSysErrorCode());
239 void WXDLLEXPORT
wxLogSysError(long lErrCode
, const wxChar
*szFormat
, ...)
242 va_start(argptr
, szFormat
);
243 wxVsprintf(s_szBuf
, szFormat
, argptr
);
246 wxLogSysErrorHelper(lErrCode
);
249 // ----------------------------------------------------------------------------
250 // wxLog class implementation
251 // ----------------------------------------------------------------------------
255 m_bHasMessages
= FALSE
;
257 // enable verbose messages by default in the debug builds
262 #endif // debug/release
265 wxLog
*wxLog::GetActiveTarget()
267 if ( ms_bAutoCreate
&& ms_pLogger
== NULL
) {
268 // prevent infinite recursion if someone calls wxLogXXX() from
269 // wxApp::CreateLogTarget()
270 static bool s_bInGetActiveTarget
= FALSE
;
271 if ( !s_bInGetActiveTarget
) {
272 s_bInGetActiveTarget
= TRUE
;
275 ms_pLogger
= new wxLogStderr
;
277 // ask the application to create a log target for us
278 if ( wxTheApp
!= NULL
)
279 ms_pLogger
= wxTheApp
->CreateLogTarget();
281 ms_pLogger
= new wxLogStderr
;
284 s_bInGetActiveTarget
= FALSE
;
286 // do nothing if it fails - what can we do?
293 wxLog
*wxLog::SetActiveTarget(wxLog
*pLogger
)
295 if ( ms_pLogger
!= NULL
) {
296 // flush the old messages before changing because otherwise they might
297 // get lost later if this target is not restored
301 wxLog
*pOldLogger
= ms_pLogger
;
302 ms_pLogger
= pLogger
;
307 void wxLog::RemoveTraceMask(const wxString
& str
)
309 int index
= ms_aTraceMasks
.Index(str
);
310 if ( index
!= wxNOT_FOUND
)
311 ms_aTraceMasks
.Remove((size_t)index
);
314 void wxLog::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
319 case wxLOG_FatalError
:
320 DoLogString(str
<< _("Fatal error: ") << szString
, t
);
321 DoLogString(_("Program aborted."), t
);
327 DoLogString(str
<< _("Error: ") << szString
, t
);
331 DoLogString(str
<< _("Warning: ") << szString
, t
);
337 DoLogString(str
+ szString
, t
);
347 DoLogString(szString
, t
);
353 wxFAIL_MSG(_("unknown log level in wxLog::DoLog"));
357 void wxLog::DoLogString(const wxChar
*WXUNUSED(szString
), time_t t
)
359 wxFAIL_MSG(_T("DoLogString must be overriden if it's called."));
367 // ----------------------------------------------------------------------------
368 // wxLogStderr class implementation
369 // ----------------------------------------------------------------------------
371 wxLogStderr::wxLogStderr(FILE *fp
)
379 void wxLogStderr::DoLogString(const wxChar
*szString
, time_t t
)
381 wxString
str(szString
);
384 fputs(str
.mb_str(), m_fp
);
387 // under Windows, programs usually don't have stderr at all, so make show the
388 // messages also under debugger
390 OutputDebugString(str
+ _T('\r'));
394 // ----------------------------------------------------------------------------
395 // wxLogStream implementation
396 // ----------------------------------------------------------------------------
398 #if wxUSE_STD_IOSTREAM
399 wxLogStream::wxLogStream(ostream
*ostr
)
407 void wxLogStream::DoLogString(const wxChar
*szString
, time_t t
)
409 (*m_ostr
) << szString
<< endl
<< flush
;
411 #endif // wxUSE_STD_IOSTREAM
415 // ----------------------------------------------------------------------------
416 // wxLogTextCtrl implementation
417 // ----------------------------------------------------------------------------
419 #if wxUSE_STD_IOSTREAM
420 wxLogTextCtrl::wxLogTextCtrl(wxTextCtrl
*pTextCtrl
)
421 #if !defined(NO_TEXT_WINDOW_STREAM)
422 : wxLogStream(new ostream(pTextCtrl
))
427 wxLogTextCtrl::~wxLogTextCtrl()
431 #endif // wxUSE_STD_IOSTREAM
433 // ----------------------------------------------------------------------------
434 // wxLogGui implementation (FIXME MT-unsafe)
435 // ----------------------------------------------------------------------------
442 void wxLogGui::Clear()
444 m_bErrors
= m_bWarnings
= FALSE
;
449 void wxLogGui::Flush()
451 if ( !m_bHasMessages
)
454 // do it right now to block any new calls to Flush() while we're here
455 m_bHasMessages
= FALSE
;
457 // concatenate all strings (but not too many to not overfill the msg box)
460 nMsgCount
= m_aMessages
.Count();
462 // start from the most recent message
463 for ( size_t n
= nMsgCount
; n
> 0; n
-- ) {
464 // for Windows strings longer than this value are wrapped (NT 4.0)
465 const size_t nMsgLineWidth
= 156;
467 nLines
+= (m_aMessages
[n
- 1].Len() + nMsgLineWidth
- 1) / nMsgLineWidth
;
469 if ( nLines
> 25 ) // don't put too many lines in message box
472 str
<< m_aMessages
[n
- 1] << _T("\n");
482 else if ( m_bWarnings
) {
483 title
= _("Warning");
484 style
= wxICON_EXCLAMATION
;
487 title
= _("Information");
488 style
= wxICON_INFORMATION
;
491 wxMessageBox(str
, title
, wxOK
| style
);
493 // no undisplayed messages whatsoever
497 // the default behaviour is to discard all informational messages if there
498 // are any errors/warnings.
499 void wxLogGui::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
506 m_aMessages
.Add(szString
);
507 m_aTimes
.Add((long)t
);
508 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
);
533 // don't prepend debug/trace here: it goes to the
534 // debug window anyhow, but do put a timestamp
535 OutputDebugString(wxString(szString
) + _T("\n\r"));
537 // send them to stderr
538 wxFprintf(stderr
, _T("%s: %s\n"),
539 level
== wxLOG_Trace
? _T("Trace") : _T("Debug"),
544 #endif // __WXDEBUG__
548 case wxLOG_FatalError
:
549 // show this one immediately
550 wxMessageBox(szString
, _("Fatal error"), wxICON_HAND
);
554 // discard earlier informational messages if this is the 1st
555 // error because they might not make sense any more
559 m_bHasMessages
= TRUE
;
566 // for the warning we don't discard the info messages
570 m_aMessages
.Add(szString
);
571 m_aTimes
.Add((long)t
);
575 wxFAIL_MSG(_("unknown log level in wxLogGui::DoLog"));
579 // ----------------------------------------------------------------------------
580 // wxLogWindow and wxLogFrame implementation
581 // ----------------------------------------------------------------------------
585 class wxLogFrame
: public wxFrame
589 wxLogFrame(wxFrame
*pParent
, wxLogWindow
*log
, const wxChar
*szTitle
);
590 virtual ~wxLogFrame();
593 void OnClose(wxCommandEvent
& event
);
594 void OnCloseWindow(wxCloseEvent
& event
);
595 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
)
623 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
;
643 pMenu
->Append(Menu_Save
, _("&Save..."), _("Save log contents to file"));
644 pMenu
->Append(Menu_Clear
, _("C&lear"), _("Clear the log contents"));
645 pMenu
->AppendSeparator();
646 pMenu
->Append(Menu_Close
, _("&Close"), _("Close this window"));
647 pMenuBar
->Append(pMenu
, _("&Log"));
648 SetMenuBar(pMenuBar
);
650 // status bar for menu prompts
653 m_log
->OnFrameCreate(this);
656 void wxLogFrame::OnClose(wxCommandEvent
& WXUNUSED(event
))
661 void wxLogFrame::OnCloseWindow(wxCloseEvent
& WXUNUSED(event
))
666 void wxLogFrame::OnSave(wxCommandEvent
& WXUNUSED(event
))
670 const wxChar
*szFileName
= wxSaveFileSelector(_T("log"), _T("txt"), _T("log.txt"));
671 if ( szFileName
== NULL
) {
680 if ( wxFile::Exists(szFileName
) ) {
681 bool bAppend
= FALSE
;
683 strMsg
.Printf(_("Append log to file '%s' "
684 "(choosing [No] will overwrite it)?"), szFileName
);
685 switch ( wxMessageBox(strMsg
, _("Question"), wxYES_NO
| wxCANCEL
) ) {
698 wxFAIL_MSG(_("invalid message box return value"));
702 bOk
= file
.Open(szFileName
, wxFile::write_append
);
705 bOk
= file
.Create(szFileName
, TRUE
/* overwrite */);
709 bOk
= file
.Create(szFileName
);
712 // retrieve text and save it
713 // -------------------------
714 int nLines
= m_pTextCtrl
->GetNumberOfLines();
715 for ( int nLine
= 0; bOk
&& nLine
< nLines
; nLine
++ ) {
716 bOk
= file
.Write(m_pTextCtrl
->GetLineText(nLine
) +
717 // we're not going to pull in the whole wxTextFile if all we need is this...
720 #else // !wxUSE_TEXTFILE
722 #endif // wxUSE_TEXTFILE
730 wxLogError(_("Can't save log contents to file."));
733 wxLogStatus(this, _("Log saved to the file '%s'."), szFileName
);
737 void wxLogFrame::OnClear(wxCommandEvent
& WXUNUSED(event
))
739 m_pTextCtrl
->Clear();
742 wxLogFrame::~wxLogFrame()
744 m_log
->OnFrameDelete(this);
749 wxLogWindow::wxLogWindow(wxFrame
*pParent
,
750 const wxChar
*szTitle
,
754 m_bPassMessages
= bDoPass
;
756 m_pLogFrame
= new wxLogFrame(pParent
, this, szTitle
);
757 m_pOldLog
= wxLog::SetActiveTarget(this);
760 m_pLogFrame
->Show(TRUE
);
763 void wxLogWindow::Show(bool bShow
)
765 m_pLogFrame
->Show(bShow
);
768 void wxLogWindow::Flush()
770 if ( m_pOldLog
!= NULL
)
773 m_bHasMessages
= FALSE
;
776 void wxLogWindow::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
778 // first let the previous logger show it
779 if ( m_pOldLog
!= NULL
&& m_bPassMessages
) {
780 // FIXME why can't we access protected wxLog method from here (we derive
781 // from wxLog)? gcc gives "DoLog is protected in this context", what
782 // does this mean? Anyhow, the cast is harmless and let's us do what
784 ((wxLogWindow
*)m_pOldLog
)->DoLog(level
, szString
, t
);
790 // by default, these messages are ignored by wxLog, so process
794 str
<< _("Status: ") << szString
;
799 // don't put trace messages in the text window for 2 reasons:
800 // 1) there are too many of them
801 // 2) they may provoke other trace messages thus sending a program
802 // into an infinite loop
807 // and this will format it nicely and call our DoLogString()
808 wxLog::DoLog(level
, szString
, t
);
812 m_bHasMessages
= TRUE
;
815 void wxLogWindow::DoLogString(const wxChar
*szString
, time_t t
)
817 // put the text into our window
818 wxTextCtrl
*pText
= m_pLogFrame
->TextCtrl();
820 // remove selection (WriteText is in fact ReplaceSelection)
822 long nLen
= pText
->GetLastPosition();
823 pText
->SetSelection(nLen
, nLen
);
826 pText
->WriteText(szString
);
827 pText
->WriteText(_T("\n")); // "\n" ok here (_not_ "\r\n")
829 // TODO ensure that the line can be seen
832 wxFrame
*wxLogWindow::GetFrame() const
837 void wxLogWindow::OnFrameCreate(wxFrame
* WXUNUSED(frame
))
841 void wxLogWindow::OnFrameDelete(wxFrame
* WXUNUSED(frame
))
843 m_pLogFrame
= (wxLogFrame
*)NULL
;
846 wxLogWindow::~wxLogWindow()
850 // may be NULL if log frame already auto destroyed itself
856 // ============================================================================
857 // Global functions/variables
858 // ============================================================================
860 // ----------------------------------------------------------------------------
862 // ----------------------------------------------------------------------------
864 wxLog
*wxLog::ms_pLogger
= (wxLog
*)NULL
;
865 bool wxLog::ms_doLog
= TRUE
;
866 bool wxLog::ms_bAutoCreate
= TRUE
;
867 wxTraceMask
wxLog::ms_ulTraceMask
= (wxTraceMask
)0;
868 wxArrayString
wxLog::ms_aTraceMasks
;
870 // ----------------------------------------------------------------------------
871 // stdout error logging helper
872 // ----------------------------------------------------------------------------
874 // helper function: wraps the message and justifies it under given position
875 // (looks more pretty on the terminal). Also adds newline at the end.
877 // TODO this is now disabled until I find a portable way of determining the
878 // terminal window size (ok, I found it but does anybody really cares?)
879 #ifdef LOG_PRETTY_WRAP
880 static void wxLogWrap(FILE *f
, const char *pszPrefix
, const char *psz
)
882 size_t nMax
= 80; // FIXME
883 size_t nStart
= strlen(pszPrefix
);
887 while ( *psz
!= '\0' ) {
888 for ( n
= nStart
; (n
< nMax
) && (*psz
!= '\0'); n
++ )
892 if ( *psz
!= '\0' ) {
894 for ( n
= 0; n
< nStart
; n
++ )
897 // as we wrapped, squeeze all white space
898 while ( isspace(*psz
) )
905 #endif //LOG_PRETTY_WRAP
907 // ----------------------------------------------------------------------------
908 // error code/error message retrieval functions
909 // ----------------------------------------------------------------------------
911 // get error code from syste
912 unsigned long wxSysErrorCode()
916 return ::GetLastError();
918 // TODO what to do on Windows 3.1?
926 // get error message from system
927 const wxChar
*wxSysErrorMsg(unsigned long nErrCode
)
930 nErrCode
= wxSysErrorCode();
934 static wxChar s_szBuf
[LOG_BUFFER_SIZE
/ 2];
936 // get error message from system
938 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
,
940 MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
),
944 // copy it to our buffer and free memory
945 wxStrncpy(s_szBuf
, (const wxChar
*)lpMsgBuf
, WXSIZEOF(s_szBuf
) - 1);
946 s_szBuf
[WXSIZEOF(s_szBuf
) - 1] = _T('\0');
949 // returned string is capitalized and ended with '\r\n' - bad
950 s_szBuf
[0] = (wxChar
)wxTolower(s_szBuf
[0]);
951 size_t len
= wxStrlen(s_szBuf
);
954 if ( s_szBuf
[len
- 2] == _T('\r') )
955 s_szBuf
[len
- 2] = _T('\0');
965 static wxChar s_szBuf
[LOG_BUFFER_SIZE
/ 2];
966 wxConv_libc
.MB2WC(s_szBuf
, strerror(nErrCode
), WXSIZEOF(s_szBuf
) -1);
969 return strerror(nErrCode
);
974 // ----------------------------------------------------------------------------
976 // ----------------------------------------------------------------------------
980 // break into the debugger
985 #elif defined(__WXMAC__)
991 #elif defined(__UNIX__)
998 // this function is called when an assert fails
999 void wxOnAssert(const char *szFile
, int nLine
, const wxChar
*szMsg
)
1001 // this variable can be set to true to suppress "assert failure" messages
1002 static bool s_bNoAsserts
= FALSE
;
1003 static bool s_bInAssert
= FALSE
; // FIXME MT-unsafe
1005 if ( s_bInAssert
) {
1006 // He-e-e-e-elp!! we're trapped in endless loop
1009 s_bInAssert
= FALSE
;
1016 wxChar szBuf
[LOG_BUFFER_SIZE
];
1018 // make life easier for people using VC++ IDE: clicking on the message
1019 // will take us immediately to the place of the failed assert
1021 wxSprintf(szBuf
, _T("%s(%d): assert failed"), szFile
, nLine
);
1023 // make the error message more clear for all the others
1025 wxSprintf(szBuf
, _T("Assert failed in file %s at line %d"), szFile
, nLine
);
1027 wxSprintf(szBuf
, _T("Assert failed in file %hs at line %d"), szFile
, nLine
);
1031 if ( szMsg
!= NULL
) {
1032 wxStrcat(szBuf
, _T(": "));
1033 wxStrcat(szBuf
, szMsg
);
1036 wxStrcat(szBuf
, _T("."));
1039 if ( !s_bNoAsserts
) {
1040 // send it to the normal log destination
1046 // this message is intentionally not translated - it is for
1048 wxStrcat(szBuf
, _T("\nDo you want to stop the program?"
1049 "\nYou can also choose [Cancel] to suppress "
1050 "further warnings."));
1052 switch ( wxMessageBox(szBuf
, _("Debug"),
1053 wxYES_NO
| wxCANCEL
| wxICON_STOP
) ) {
1059 s_bNoAsserts
= TRUE
;
1062 //case wxNO: nothing to do
1067 s_bInAssert
= FALSE
;