X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0adad2d72ffb322510e78ea366c58adbd1e8082e..957686c882df820c73e2e35732969a4da8d72098:/src/common/log.cpp diff --git a/src/common/log.cpp b/src/common/log.cpp index 3731fe3865..9d9b21c660 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -60,6 +60,10 @@ #include "wx/msw/private.h" // includes windows.h for OutputDebugString #endif +#if defined(__WXMAC__) + #include "wx/mac/private.h" // includes mac headers +#endif + // ---------------------------------------------------------------------------- // non member functions // ---------------------------------------------------------------------------- @@ -107,33 +111,42 @@ static inline bool IsLoggingEnabled() // ---------------------------------------------------------------------------- // generic log function -void wxLogGeneric(wxLogLevel level, const wxChar *szFormat, ...) +void wxVLogGeneric(wxLogLevel level, const wxChar *szFormat, va_list argptr) { if ( IsLoggingEnabled() ) { wxCRIT_SECT_LOCKER(locker, gs_csLogBuf); - va_list argptr; - va_start(argptr, szFormat); wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr); - va_end(argptr); wxLog::OnLog(level, s_szBuf, time(NULL)); } } +void wxLogGeneric(wxLogLevel level, const wxChar *szFormat, ...) +{ + va_list argptr; + va_start(argptr, szFormat); + wxVLogGeneric(level, szFormat, argptr); + va_end(argptr); +} + #define IMPLEMENT_LOG_FUNCTION(level) \ - void wxLog##level(const wxChar *szFormat, ...) \ + void wxVLog##level(const wxChar *szFormat, va_list argptr) \ { \ if ( IsLoggingEnabled() ) { \ wxCRIT_SECT_LOCKER(locker, gs_csLogBuf); \ \ - va_list argptr; \ - va_start(argptr, szFormat); \ wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr); \ - va_end(argptr); \ \ wxLog::OnLog(wxLOG_##level, s_szBuf, time(NULL)); \ } \ + } \ + void wxLog##level(const wxChar *szFormat, ...) \ + { \ + va_list argptr; \ + va_start(argptr, szFormat); \ + wxVLog##level(szFormat, argptr); \ + va_end(argptr); \ } IMPLEMENT_LOG_FUNCTION(FatalError) @@ -144,41 +157,50 @@ IMPLEMENT_LOG_FUNCTION(Info) IMPLEMENT_LOG_FUNCTION(Status) // same as info, but only if 'verbose' mode is on -void wxLogVerbose(const wxChar *szFormat, ...) +void wxVLogVerbose(const wxChar *szFormat, va_list argptr) { if ( IsLoggingEnabled() ) { wxLog *pLog = wxLog::GetActiveTarget(); if ( pLog != NULL && pLog->GetVerbose() ) { wxCRIT_SECT_LOCKER(locker, gs_csLogBuf); - va_list argptr; - va_start(argptr, szFormat); wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr); - va_end(argptr); wxLog::OnLog(wxLOG_Info, s_szBuf, time(NULL)); } } } +void wxLogVerbose(const wxChar *szFormat, ...) +{ + va_list argptr; + va_start(argptr, szFormat); + wxVLogVerbose(szFormat, argptr); + va_end(argptr); +} + // debug functions #ifdef __WXDEBUG__ #define IMPLEMENT_LOG_DEBUG_FUNCTION(level) \ - void wxLog##level(const wxChar *szFormat, ...) \ + void wxVLog##level(const wxChar *szFormat, va_list argptr) \ { \ if ( IsLoggingEnabled() ) { \ wxCRIT_SECT_LOCKER(locker, gs_csLogBuf); \ \ - va_list argptr; \ - va_start(argptr, szFormat); \ wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr); \ - va_end(argptr); \ \ wxLog::OnLog(wxLOG_##level, s_szBuf, time(NULL)); \ } \ + } \ + void wxLog##level(const wxChar *szFormat, ...) \ + { \ + va_list argptr; \ + va_start(argptr, szFormat); \ + wxVLog##level(szFormat, argptr); \ + va_end(argptr); \ } - void wxLogTrace(const wxChar *mask, const wxChar *szFormat, ...) + void wxVLogTrace(const wxChar *mask, const wxChar *szFormat, va_list argptr) { if ( IsLoggingEnabled() && wxLog::IsAllowedTraceMask(mask) ) { wxCRIT_SECT_LOCKER(locker, gs_csLogBuf); @@ -197,16 +219,21 @@ void wxLogVerbose(const wxChar *szFormat, ...) len -= 2; p += 2; - va_list argptr; - va_start(argptr, szFormat); wxVsnprintf(p, len, szFormat, argptr); - va_end(argptr); - + wxLog::OnLog(wxLOG_Trace, s_szBuf, time(NULL)); } } - void wxLogTrace(wxTraceMask mask, const wxChar *szFormat, ...) + void wxLogTrace(const wxChar *mask, const wxChar *szFormat, ...) + { + va_list argptr; + va_start(argptr, szFormat); + wxVLogTrace(mask, szFormat, argptr); + va_end(argptr); + } + + void wxVLogTrace(wxTraceMask mask, const wxChar *szFormat, va_list argptr) { // we check that all of mask bits are set in the current mask, so // that wxLogTrace(wxTraceRefCount | wxTraceOle) will only do something @@ -214,15 +241,20 @@ void wxLogVerbose(const wxChar *szFormat, ...) if ( IsLoggingEnabled() && ((wxLog::GetTraceMask() & mask) == mask) ) { wxCRIT_SECT_LOCKER(locker, gs_csLogBuf); - va_list argptr; - va_start(argptr, szFormat); wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr); - va_end(argptr); wxLog::OnLog(wxLOG_Trace, s_szBuf, time(NULL)); } } + void wxLogTrace(wxTraceMask mask, const wxChar *szFormat, ...) + { + va_list argptr; + va_start(argptr, szFormat); + wxVLogTrace(mask, szFormat, argptr); + va_end(argptr); + } + #else // release #define IMPLEMENT_LOG_DEBUG_FUNCTION(level) #endif @@ -244,34 +276,44 @@ void wxLogSysErrorHelper(long lErrCode) wxLog::OnLog(wxLOG_Error, s_szBuf, time(NULL)); } -void WXDLLEXPORT wxLogSysError(const wxChar *szFormat, ...) +void WXDLLEXPORT wxVLogSysError(const wxChar *szFormat, va_list argptr) { if ( IsLoggingEnabled() ) { wxCRIT_SECT_LOCKER(locker, gs_csLogBuf); - va_list argptr; - va_start(argptr, szFormat); wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr); - va_end(argptr); wxLogSysErrorHelper(wxSysErrorCode()); } } -void WXDLLEXPORT wxLogSysError(long lErrCode, const wxChar *szFormat, ...) +void WXDLLEXPORT wxLogSysError(const wxChar *szFormat, ...) +{ + va_list argptr; + va_start(argptr, szFormat); + wxVLogSysError(szFormat, argptr); + va_end(argptr); +} + +void WXDLLEXPORT wxVLogSysError(long lErrCode, const wxChar *szFormat, va_list argptr) { if ( IsLoggingEnabled() ) { wxCRIT_SECT_LOCKER(locker, gs_csLogBuf); - va_list argptr; - va_start(argptr, szFormat); wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr); - va_end(argptr); wxLogSysErrorHelper(lErrCode); } } +void WXDLLEXPORT wxLogSysError(long lErrCode, const wxChar *szFormat, ...) +{ + va_list argptr; + va_start(argptr, szFormat); + wxVLogSysError(lErrCode, szFormat, argptr); + va_end(argptr); +} + // ---------------------------------------------------------------------------- // wxLog class implementation // ---------------------------------------------------------------------------- @@ -418,7 +460,10 @@ wxLogStderr::wxLogStderr(FILE *fp) m_fp = fp; } -#if defined(__WXMAC__) && !defined(__DARWIN__) +#if defined(__WXMAC__) && !defined(__DARWIN__) && (__MWERKS__ > 0x5300) + +#if !TARGET_API_MAC_CARBON +// MetroNub stuff doesn't seem to work in CodeWarrior 5.3 Carbon builds... #ifndef __MetroNubUtils__ #include "MetroNubUtils.h" @@ -601,7 +646,9 @@ OSErr ClearWatchPoint (WatchPointIDT watchPointID) } #endif -#endif +#endif // !TARGET_API_MAC_CARBON + +#endif // defined(__WXMAC__) && !defined(__DARWIN__) && (__MWERKS__ > 0x5300) void wxLogStderr::DoLogString(const wxChar *szString, time_t WXUNUSED(t)) { @@ -627,11 +674,15 @@ void wxLogStderr::DoLogString(const wxChar *szString, time_t WXUNUSED(t)) Boolean running = false ; +#if !TARGET_API_MAC_CARBON && (__MWERKS__ > 0x5300) + if ( IsMWDebuggerRunning() && AmIBeingMWDebugged() ) { running = true ; } +#endif + if (running) { #ifdef __powerc