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 licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "log.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
33 #include "wx/string.h"
38 #include "wx/window.h"
39 #include "wx/msgdlg.h"
41 #include "wx/msw/private.h"
47 #include "wx/textfile.h"
49 #include "wx/wxchar.h"
51 #include "wx/thread.h"
55 // other standard headers
60 #if defined(__WXMSW__)
61 #include "wx/msw/private.h" // includes windows.h for OutputDebugString
64 #if defined(__WXMAC__)
65 #include "wx/mac/private.h" // includes mac headers
68 #if defined(__MWERKS__) && wxUSE_UNICODE
73 // ----------------------------------------------------------------------------
74 // non member functions
75 // ----------------------------------------------------------------------------
77 // define this to enable wrapping of log messages
78 //#define LOG_PRETTY_WRAP
80 #ifdef LOG_PRETTY_WRAP
81 static void wxLogWrap(FILE *f
, const char *pszPrefix
, const char *psz
);
84 // ============================================================================
86 // ============================================================================
88 // ----------------------------------------------------------------------------
90 // ----------------------------------------------------------------------------
92 // log functions can't allocate memory (LogError("out of memory...") should
93 // work!), so we use a static buffer for all log messages
94 #define LOG_BUFFER_SIZE (4096)
96 // static buffer for error messages
97 static wxChar s_szBufStatic
[LOG_BUFFER_SIZE
];
99 static wxChar
*s_szBuf
= s_szBufStatic
;
100 static size_t s_szBufSize
= WXSIZEOF( s_szBufStatic
);
104 // the critical section protecting the static buffer
105 static wxCriticalSection gs_csLogBuf
;
107 #endif // wxUSE_THREADS
109 // return true if we have a non NULL non disabled log target
110 static inline bool IsLoggingEnabled()
112 return wxLog::IsEnabled() && (wxLog::GetActiveTarget() != NULL
);
115 // ----------------------------------------------------------------------------
116 // implementation of Log functions
118 // NB: unfortunately we need all these distinct functions, we can't make them
119 // macros and not all compilers inline vararg functions.
120 // ----------------------------------------------------------------------------
122 // wrapper for wxVsnprintf(s_szBuf) which always NULL-terminates it
123 static inline void PrintfInLogBug(const wxChar
*szFormat
, va_list argptr
)
125 if ( wxVsnprintf(s_szBuf
, s_szBufSize
, szFormat
, argptr
) < 0 )
127 // must NUL-terminate it manually
128 s_szBuf
[s_szBufSize
- 1] = _T('\0');
130 //else: NUL-terminated by vsnprintf()
133 // generic log function
134 void wxVLogGeneric(wxLogLevel level
, const wxChar
*szFormat
, va_list argptr
)
136 if ( IsLoggingEnabled() ) {
137 wxCRIT_SECT_LOCKER(locker
, gs_csLogBuf
);
139 PrintfInLogBug(szFormat
, argptr
);
141 wxLog::OnLog(level
, s_szBuf
, time(NULL
));
145 void wxLogGeneric(wxLogLevel level
, const wxChar
*szFormat
, ...)
148 va_start(argptr
, szFormat
);
149 wxVLogGeneric(level
, szFormat
, argptr
);
153 #define IMPLEMENT_LOG_FUNCTION(level) \
154 void wxVLog##level(const wxChar *szFormat, va_list argptr) \
156 if ( IsLoggingEnabled() ) { \
157 wxCRIT_SECT_LOCKER(locker, gs_csLogBuf); \
159 PrintfInLogBug(szFormat, argptr); \
161 wxLog::OnLog(wxLOG_##level, s_szBuf, time(NULL)); \
165 void wxLog##level(const wxChar *szFormat, ...) \
168 va_start(argptr, szFormat); \
169 wxVLog##level(szFormat, argptr); \
173 IMPLEMENT_LOG_FUNCTION(Error
)
174 IMPLEMENT_LOG_FUNCTION(Warning
)
175 IMPLEMENT_LOG_FUNCTION(Message
)
176 IMPLEMENT_LOG_FUNCTION(Info
)
177 IMPLEMENT_LOG_FUNCTION(Status
)
179 void wxSafeShowMessage(const wxString
& title
, const wxString
& text
)
182 ::MessageBox(NULL
, text
, title
, MB_OK
| MB_ICONSTOP
);
184 wxFprintf(stderr
, _T("%s: %s\n"), title
.c_str(), text
.c_str());
188 // fatal errors can't be suppressed nor handled by the custom log target and
189 // always terminate the program
190 void wxVLogFatalError(const wxChar
*szFormat
, va_list argptr
)
192 wxVsnprintf(s_szBuf
, s_szBufSize
, szFormat
, argptr
);
194 wxSafeShowMessage(_T("Fatal Error"), s_szBuf
);
199 void wxLogFatalError(const wxChar
*szFormat
, ...)
202 va_start(argptr
, szFormat
);
203 wxVLogFatalError(szFormat
, argptr
);
207 // same as info, but only if 'verbose' mode is on
208 void wxVLogVerbose(const wxChar
*szFormat
, va_list argptr
)
210 if ( IsLoggingEnabled() ) {
211 wxLog
*pLog
= wxLog::GetActiveTarget();
212 if ( pLog
!= NULL
&& pLog
->GetVerbose() ) {
213 wxCRIT_SECT_LOCKER(locker
, gs_csLogBuf
);
215 wxVsnprintf(s_szBuf
, s_szBufSize
, szFormat
, argptr
);
217 wxLog::OnLog(wxLOG_Info
, s_szBuf
, time(NULL
));
222 void wxLogVerbose(const wxChar
*szFormat
, ...)
225 va_start(argptr
, szFormat
);
226 wxVLogVerbose(szFormat
, argptr
);
232 #define IMPLEMENT_LOG_DEBUG_FUNCTION(level) \
233 void wxVLog##level(const wxChar *szFormat, va_list argptr) \
235 if ( IsLoggingEnabled() ) { \
236 wxCRIT_SECT_LOCKER(locker, gs_csLogBuf); \
238 wxVsnprintf(s_szBuf, s_szBufSize, szFormat, argptr); \
240 wxLog::OnLog(wxLOG_##level, s_szBuf, time(NULL)); \
243 void wxLog##level(const wxChar *szFormat, ...) \
246 va_start(argptr, szFormat); \
247 wxVLog##level(szFormat, argptr); \
251 void wxVLogTrace(const wxChar
*mask
, const wxChar
*szFormat
, va_list argptr
)
253 if ( IsLoggingEnabled() && wxLog::IsAllowedTraceMask(mask
) ) {
254 wxCRIT_SECT_LOCKER(locker
, gs_csLogBuf
);
257 size_t len
= s_szBufSize
;
258 wxStrncpy(s_szBuf
, _T("("), len
);
259 len
-= 1; // strlen("(")
261 wxStrncat(p
, mask
, len
);
262 size_t lenMask
= wxStrlen(mask
);
266 wxStrncat(p
, _T(") "), len
);
270 wxVsnprintf(p
, len
, szFormat
, argptr
);
272 wxLog::OnLog(wxLOG_Trace
, s_szBuf
, time(NULL
));
276 void wxLogTrace(const wxChar
*mask
, const wxChar
*szFormat
, ...)
279 va_start(argptr
, szFormat
);
280 wxVLogTrace(mask
, szFormat
, argptr
);
284 void wxVLogTrace(wxTraceMask mask
, const wxChar
*szFormat
, va_list argptr
)
286 // we check that all of mask bits are set in the current mask, so
287 // that wxLogTrace(wxTraceRefCount | wxTraceOle) will only do something
288 // if both bits are set.
289 if ( IsLoggingEnabled() && ((wxLog::GetTraceMask() & mask
) == mask
) ) {
290 wxCRIT_SECT_LOCKER(locker
, gs_csLogBuf
);
292 wxVsnprintf(s_szBuf
, s_szBufSize
, szFormat
, argptr
);
294 wxLog::OnLog(wxLOG_Trace
, s_szBuf
, time(NULL
));
298 void wxLogTrace(wxTraceMask mask
, const wxChar
*szFormat
, ...)
301 va_start(argptr
, szFormat
);
302 wxVLogTrace(mask
, szFormat
, argptr
);
307 #define IMPLEMENT_LOG_DEBUG_FUNCTION(level)
310 IMPLEMENT_LOG_DEBUG_FUNCTION(Debug
)
311 IMPLEMENT_LOG_DEBUG_FUNCTION(Trace
)
313 // wxLogSysError: one uses the last error code, for other you must give it
316 // common part of both wxLogSysError
317 void wxLogSysErrorHelper(long lErrCode
)
319 wxChar szErrMsg
[LOG_BUFFER_SIZE
/ 2];
320 wxSnprintf(szErrMsg
, WXSIZEOF(szErrMsg
),
321 _(" (error %ld: %s)"), lErrCode
, wxSysErrorMsg(lErrCode
));
322 wxStrncat(s_szBuf
, szErrMsg
, s_szBufSize
- wxStrlen(s_szBuf
));
324 wxLog::OnLog(wxLOG_Error
, s_szBuf
, time(NULL
));
327 void WXDLLEXPORT
wxVLogSysError(const wxChar
*szFormat
, va_list argptr
)
329 if ( IsLoggingEnabled() ) {
330 wxCRIT_SECT_LOCKER(locker
, gs_csLogBuf
);
332 wxVsnprintf(s_szBuf
, s_szBufSize
, szFormat
, argptr
);
334 wxLogSysErrorHelper(wxSysErrorCode());
338 void WXDLLEXPORT
wxLogSysError(const wxChar
*szFormat
, ...)
341 va_start(argptr
, szFormat
);
342 wxVLogSysError(szFormat
, argptr
);
346 void WXDLLEXPORT
wxVLogSysError(long lErrCode
, const wxChar
*szFormat
, va_list argptr
)
348 if ( IsLoggingEnabled() ) {
349 wxCRIT_SECT_LOCKER(locker
, gs_csLogBuf
);
351 wxVsnprintf(s_szBuf
, s_szBufSize
, szFormat
, argptr
);
353 wxLogSysErrorHelper(lErrCode
);
357 void WXDLLEXPORT
wxLogSysError(long lErrCode
, const wxChar
*szFormat
, ...)
360 va_start(argptr
, szFormat
);
361 wxVLogSysError(lErrCode
, szFormat
, argptr
);
365 // ----------------------------------------------------------------------------
366 // wxLog class implementation
367 // ----------------------------------------------------------------------------
373 wxChar
*wxLog::SetLogBuffer( wxChar
*buf
, size_t size
)
375 wxChar
*oldbuf
= s_szBuf
;
379 s_szBuf
= s_szBufStatic
;
380 s_szBufSize
= WXSIZEOF( s_szBufStatic
);
388 return (oldbuf
== s_szBufStatic
) ? 0 : oldbuf
;
391 wxLog
*wxLog::GetActiveTarget()
393 if ( ms_bAutoCreate
&& ms_pLogger
== NULL
) {
394 // prevent infinite recursion if someone calls wxLogXXX() from
395 // wxApp::CreateLogTarget()
396 static bool s_bInGetActiveTarget
= FALSE
;
397 if ( !s_bInGetActiveTarget
) {
398 s_bInGetActiveTarget
= TRUE
;
400 // ask the application to create a log target for us
401 if ( wxTheApp
!= NULL
)
402 ms_pLogger
= wxTheApp
->CreateLogTarget();
404 ms_pLogger
= new wxLogStderr
;
406 s_bInGetActiveTarget
= FALSE
;
408 // do nothing if it fails - what can we do?
415 wxLog
*wxLog::SetActiveTarget(wxLog
*pLogger
)
417 if ( ms_pLogger
!= NULL
) {
418 // flush the old messages before changing because otherwise they might
419 // get lost later if this target is not restored
423 wxLog
*pOldLogger
= ms_pLogger
;
424 ms_pLogger
= pLogger
;
429 void wxLog::DontCreateOnDemand()
431 ms_bAutoCreate
= FALSE
;
433 // this is usually called at the end of the program and we assume that it
434 // is *always* called at the end - so we free memory here to avoid false
435 // memory leak reports from wxWin memory tracking code
439 void wxLog::RemoveTraceMask(const wxString
& str
)
441 int index
= ms_aTraceMasks
.Index(str
);
442 if ( index
!= wxNOT_FOUND
)
443 ms_aTraceMasks
.Remove((size_t)index
);
446 void wxLog::ClearTraceMasks()
448 ms_aTraceMasks
.Clear();
451 void wxLog::TimeStamp(wxString
*str
)
457 (void)time(&timeNow
);
458 wxStrftime(buf
, WXSIZEOF(buf
), ms_timestamp
, localtime(&timeNow
));
461 *str
<< buf
<< wxT(": ");
465 void wxLog::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
468 case wxLOG_FatalError
:
469 DoLogString(wxString(_("Fatal error: ")) + szString
, t
);
470 DoLogString(_("Program aborted."), t
);
476 DoLogString(wxString(_("Error: ")) + szString
, t
);
480 DoLogString(wxString(_("Warning: ")) + szString
, t
);
487 default: // log unknown log levels too
488 DoLogString(szString
, t
);
495 wxString msg
= level
== wxLOG_Trace
? wxT("Trace: ")
505 void wxLog::DoLogString(const wxChar
*WXUNUSED(szString
), time_t WXUNUSED(t
))
507 wxFAIL_MSG(wxT("DoLogString must be overriden if it's called."));
512 // nothing to do here
515 // ----------------------------------------------------------------------------
516 // wxLogStderr class implementation
517 // ----------------------------------------------------------------------------
519 wxLogStderr::wxLogStderr(FILE *fp
)
527 #if defined(__WXMAC__) && !defined(__DARWIN__) && defined(__MWERKS__) && (__MWERKS__ >= 0x2400)
529 // MetroNub stuff doesn't seem to work in CodeWarrior 5.3 Carbon builds...
531 #ifndef __MetroNubUtils__
532 #include "MetroNubUtils.h"
551 #if TARGET_API_MAC_CARBON
553 #include <CodeFragments.h>
556 CallUniversalProc(UniversalProcPtr theProcPtr
, ProcInfoType procInfo
, ...);
558 ProcPtr gCallUniversalProc_Proc
= NULL
;
562 static MetroNubUserEntryBlock
* gMetroNubEntry
= NULL
;
564 static long fRunOnce
= false;
566 Boolean
IsCompatibleVersion(short inVersion
);
568 /* ---------------------------------------------------------------------------
570 --------------------------------------------------------------------------- */
572 Boolean
IsCompatibleVersion(short inVersion
)
574 Boolean result
= false;
578 MetroNubUserEntryBlock
* block
= (MetroNubUserEntryBlock
*)result
;
580 result
= (inVersion
<= block
->apiHiVersion
);
586 /* ---------------------------------------------------------------------------
588 --------------------------------------------------------------------------- */
590 Boolean
IsMetroNubInstalled()
597 gMetroNubEntry
= NULL
;
599 if (Gestalt(gestaltSystemVersion
, &value
) == noErr
&& value
< 0x1000)
601 /* look for MetroNub's Gestalt selector */
602 if (Gestalt(kMetroNubUserSignature
, &result
) == noErr
)
605 #if TARGET_API_MAC_CARBON
606 if (gCallUniversalProc_Proc
== NULL
)
608 CFragConnectionID connectionID
;
611 ProcPtr symbolAddress
;
613 CFragSymbolClass symbolClass
;
615 symbolAddress
= NULL
;
616 err
= GetSharedLibrary("\pInterfaceLib", kPowerPCCFragArch
, kFindCFrag
,
617 &connectionID
, &mainAddress
, errorString
);
621 gCallUniversalProc_Proc
= NULL
;
625 err
= FindSymbol(connectionID
, "\pCallUniversalProc",
626 (Ptr
*) &gCallUniversalProc_Proc
, &symbolClass
);
630 gCallUniversalProc_Proc
= NULL
;
637 MetroNubUserEntryBlock
* block
= (MetroNubUserEntryBlock
*)result
;
639 /* make sure the version of the API is compatible */
640 if (block
->apiLowVersion
<= kMetroNubUserAPIVersion
&&
641 kMetroNubUserAPIVersion
<= block
->apiHiVersion
)
642 gMetroNubEntry
= block
; /* success! */
651 #if TARGET_API_MAC_CARBON
652 return (gMetroNubEntry
!= NULL
&& gCallUniversalProc_Proc
!= NULL
);
654 return (gMetroNubEntry
!= NULL
);
658 /* ---------------------------------------------------------------------------
659 IsMWDebuggerRunning [v1 API]
660 --------------------------------------------------------------------------- */
662 Boolean
IsMWDebuggerRunning()
664 if (IsMetroNubInstalled())
665 return CallIsDebuggerRunningProc(gMetroNubEntry
->isDebuggerRunning
);
670 /* ---------------------------------------------------------------------------
671 AmIBeingMWDebugged [v1 API]
672 --------------------------------------------------------------------------- */
674 Boolean
AmIBeingMWDebugged()
676 if (IsMetroNubInstalled())
677 return CallAmIBeingDebuggedProc(gMetroNubEntry
->amIBeingDebugged
);
682 /* ---------------------------------------------------------------------------
683 UserSetWatchPoint [v2 API]
684 --------------------------------------------------------------------------- */
686 OSErr
UserSetWatchPoint (Ptr address
, long length
, WatchPointIDT
* watchPointID
)
688 if (IsMetroNubInstalled() && IsCompatibleVersion(kMetroNubUserAPIVersion
))
689 return CallUserSetWatchPointProc(gMetroNubEntry
->userSetWatchPoint
,
690 address
, length
, watchPointID
);
692 return errProcessIsNotClient
;
695 /* ---------------------------------------------------------------------------
696 ClearWatchPoint [v2 API]
697 --------------------------------------------------------------------------- */
699 OSErr
ClearWatchPoint (WatchPointIDT watchPointID
)
701 if (IsMetroNubInstalled() && IsCompatibleVersion(kMetroNubUserAPIVersion
))
702 return CallClearWatchPointProc(gMetroNubEntry
->clearWatchPoint
, watchPointID
);
704 return errProcessIsNotClient
;
711 #endif // defined(__WXMAC__) && !defined(__DARWIN__) && (__MWERKS__ >= 0x2400)
713 void wxLogStderr::DoLogString(const wxChar
*szString
, time_t WXUNUSED(t
))
719 fputs(str
.mb_str(), m_fp
);
720 fputc(_T('\n'), m_fp
);
723 // under Windows, programs usually don't have stderr at all, so show the
724 // messages also under debugger (unless it's a console program which does
725 // have stderr or unless this is a file logger which doesn't use stderr at
727 #if defined(__WXMSW__) && wxUSE_GUI && !defined(__WXMICROWIN__)
728 if ( m_fp
== stderr
)
731 OutputDebugString(str
.c_str());
735 #if defined(__WXMAC__) && !defined(__DARWIN__) && wxUSE_GUI
737 wxString output
= str
+ wxT(";g") ;
738 wxMacStringToPascal( output
.c_str() , pstr
) ;
740 Boolean running
= false ;
742 #if defined(__MWERKS__) && (__MWERKS__ >= 0x2400)
744 if ( IsMWDebuggerRunning() && AmIBeingMWDebugged() )
762 // ----------------------------------------------------------------------------
763 // wxLogStream implementation
764 // ----------------------------------------------------------------------------
766 #if wxUSE_STD_IOSTREAM
767 #include "wx/ioswrap.h"
768 wxLogStream::wxLogStream(wxSTD ostream
*ostr
)
771 m_ostr
= &wxSTD cerr
;
776 void wxLogStream::DoLogString(const wxChar
*szString
, time_t WXUNUSED(t
))
780 (*m_ostr
) << str
<< wxConvertWX2MB(szString
) << wxSTD endl
;
782 #endif // wxUSE_STD_IOSTREAM
784 // ----------------------------------------------------------------------------
786 // ----------------------------------------------------------------------------
788 wxLogChain::wxLogChain(wxLog
*logger
)
790 m_bPassMessages
= TRUE
;
793 m_logOld
= wxLog::SetActiveTarget(this);
796 wxLogChain::~wxLogChain()
800 if ( m_logNew
!= this )
804 void wxLogChain::SetLog(wxLog
*logger
)
806 if ( m_logNew
!= this )
812 void wxLogChain::Flush()
817 // be careful to avoid infinite recursion
818 if ( m_logNew
&& m_logNew
!= this )
822 void wxLogChain::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
824 // let the previous logger show it
825 if ( m_logOld
&& IsPassingMessages() )
827 // bogus cast just to access protected DoLog
828 ((wxLogChain
*)m_logOld
)->DoLog(level
, szString
, t
);
831 if ( m_logNew
&& m_logNew
!= this )
834 ((wxLogChain
*)m_logNew
)->DoLog(level
, szString
, t
);
838 // ----------------------------------------------------------------------------
840 // ----------------------------------------------------------------------------
843 // "'this' : used in base member initializer list" - so what?
844 #pragma warning(disable:4355)
847 wxLogPassThrough::wxLogPassThrough()
853 #pragma warning(default:4355)
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 bool wxLog::ms_bVerbose
= FALSE
;
869 wxLogLevel
wxLog::ms_logLevel
= wxLOG_Max
; // log everything by default
871 size_t wxLog::ms_suspendCount
= 0;
874 const wxChar
*wxLog::ms_timestamp
= wxT("%X"); // time only, no date
876 const wxChar
*wxLog::ms_timestamp
= NULL
; // save space
879 wxTraceMask
wxLog::ms_ulTraceMask
= (wxTraceMask
)0;
880 wxArrayString
wxLog::ms_aTraceMasks
;
882 // ----------------------------------------------------------------------------
883 // stdout error logging helper
884 // ----------------------------------------------------------------------------
886 // helper function: wraps the message and justifies it under given position
887 // (looks more pretty on the terminal). Also adds newline at the end.
889 // TODO this is now disabled until I find a portable way of determining the
890 // terminal window size (ok, I found it but does anybody really cares?)
891 #ifdef LOG_PRETTY_WRAP
892 static void wxLogWrap(FILE *f
, const char *pszPrefix
, const char *psz
)
894 size_t nMax
= 80; // FIXME
895 size_t nStart
= strlen(pszPrefix
);
899 while ( *psz
!= '\0' ) {
900 for ( n
= nStart
; (n
< nMax
) && (*psz
!= '\0'); n
++ )
904 if ( *psz
!= '\0' ) {
906 for ( n
= 0; n
< nStart
; n
++ )
909 // as we wrapped, squeeze all white space
910 while ( isspace(*psz
) )
917 #endif //LOG_PRETTY_WRAP
919 // ----------------------------------------------------------------------------
920 // error code/error message retrieval functions
921 // ----------------------------------------------------------------------------
923 // get error code from syste
924 unsigned long wxSysErrorCode()
926 #if defined(__WXMSW__) && !defined(__WXMICROWIN__)
928 return ::GetLastError();
930 // TODO what to do on Windows 3.1?
938 // get error message from system
939 const wxChar
*wxSysErrorMsg(unsigned long nErrCode
)
942 nErrCode
= wxSysErrorCode();
944 #if defined(__WXMSW__) && !defined(__WXMICROWIN__)
946 static wxChar s_szBuf
[LOG_BUFFER_SIZE
/ 2];
948 // get error message from system
950 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
,
952 MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
),
956 // copy it to our buffer and free memory
957 if( lpMsgBuf
!= 0 ) {
958 wxStrncpy(s_szBuf
, (const wxChar
*)lpMsgBuf
, WXSIZEOF(s_szBuf
) - 1);
959 s_szBuf
[WXSIZEOF(s_szBuf
) - 1] = wxT('\0');
963 // returned string is capitalized and ended with '\r\n' - bad
964 s_szBuf
[0] = (wxChar
)wxTolower(s_szBuf
[0]);
965 size_t len
= wxStrlen(s_szBuf
);
968 if ( s_szBuf
[len
- 2] == wxT('\r') )
969 s_szBuf
[len
- 2] = wxT('\0');
973 s_szBuf
[0] = wxT('\0');
983 static wxChar s_szBuf
[LOG_BUFFER_SIZE
/ 2];
984 wxConvCurrent
->MB2WC(s_szBuf
, strerror(nErrCode
), WXSIZEOF(s_szBuf
) -1);
987 return strerror((int)nErrCode
);