]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/log.cpp
Stripped out miscellaneous Motif/Xt-specific code
[wxWidgets.git] / src / common / log.cpp
index c9c4ab2776b8e87b8606a26cc2ef883493531c27..9d9b21c6608c8a32d7a0951d6bb907beb59f6fb5 100644 (file)
@@ -111,33 +111,42 @@ static inline bool IsLoggingEnabled()
 // ----------------------------------------------------------------------------
 
 // generic log function
 // ----------------------------------------------------------------------------
 
 // 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);
 
 {
     if ( IsLoggingEnabled() ) {
         wxCRIT_SECT_LOCKER(locker, gs_csLogBuf);
 
-        va_list argptr;
-        va_start(argptr, szFormat);
         wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr);
         wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr);
-        va_end(argptr);
 
         wxLog::OnLog(level, s_szBuf, time(NULL));
     }
 }
 
 
         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)                               \
 #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);                      \
                                                                     \
   {                                                                 \
     if ( IsLoggingEnabled() ) {                                     \
       wxCRIT_SECT_LOCKER(locker, gs_csLogBuf);                      \
                                                                     \
-      va_list argptr;                                               \
-      va_start(argptr, szFormat);                                   \
       wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr);    \
       wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr);    \
-      va_end(argptr);                                               \
                                                                     \
       wxLog::OnLog(wxLOG_##level, s_szBuf, time(NULL));             \
     }                                                               \
                                                                     \
       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)
   }
 
 IMPLEMENT_LOG_FUNCTION(FatalError)
@@ -148,41 +157,50 @@ IMPLEMENT_LOG_FUNCTION(Info)
 IMPLEMENT_LOG_FUNCTION(Status)
 
 // same as info, but only if 'verbose' mode is on
 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);
 
 {
     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);
             wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr);
-            va_end(argptr);
 
             wxLog::OnLog(wxLOG_Info, s_szBuf, time(NULL));
         }
     }
 }
 
 
             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)                         \
 // 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);                      \
                                                                     \
   {                                                                 \
     if ( IsLoggingEnabled() ) {                                     \
       wxCRIT_SECT_LOCKER(locker, gs_csLogBuf);                      \
                                                                     \
-      va_list argptr;                                               \
-      va_start(argptr, szFormat);                                   \
       wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr);    \
       wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr);    \
-      va_end(argptr);                                               \
                                                                     \
       wxLog::OnLog(wxLOG_##level, s_szBuf, time(NULL));             \
     }                                                               \
                                                                     \
       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);
   {
     if ( IsLoggingEnabled() && wxLog::IsAllowedTraceMask(mask) ) {
       wxCRIT_SECT_LOCKER(locker, gs_csLogBuf);
@@ -201,16 +219,21 @@ void wxLogVerbose(const wxChar *szFormat, ...)
       len -= 2;
       p += 2;
 
       len -= 2;
       p += 2;
 
-      va_list argptr;
-      va_start(argptr, szFormat);
       wxVsnprintf(p, len, szFormat, argptr);
       wxVsnprintf(p, len, szFormat, argptr);
-      va_end(argptr);
-
+      
       wxLog::OnLog(wxLOG_Trace, s_szBuf, time(NULL));
     }
   }
 
       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
   {
     // we check that all of mask bits are set in the current mask, so
     // that wxLogTrace(wxTraceRefCount | wxTraceOle) will only do something
@@ -218,15 +241,20 @@ void wxLogVerbose(const wxChar *szFormat, ...)
     if ( IsLoggingEnabled() && ((wxLog::GetTraceMask() & mask) == mask) ) {
       wxCRIT_SECT_LOCKER(locker, gs_csLogBuf);
 
     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);
       wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr);
-      va_end(argptr);
 
       wxLog::OnLog(wxLOG_Trace, s_szBuf, time(NULL));
     }
   }
 
 
       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
 #else // release
   #define IMPLEMENT_LOG_DEBUG_FUNCTION(level)
 #endif
@@ -248,34 +276,44 @@ void wxLogSysErrorHelper(long lErrCode)
     wxLog::OnLog(wxLOG_Error, s_szBuf, time(NULL));
 }
 
     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);
 
 {
     if ( IsLoggingEnabled() ) {
         wxCRIT_SECT_LOCKER(locker, gs_csLogBuf);
 
-        va_list argptr;
-        va_start(argptr, szFormat);
         wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr);
         wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr);
-        va_end(argptr);
 
         wxLogSysErrorHelper(wxSysErrorCode());
     }
 }
 
 
         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);
 
 {
     if ( IsLoggingEnabled() ) {
         wxCRIT_SECT_LOCKER(locker, gs_csLogBuf);
 
-        va_list argptr;
-        va_start(argptr, szFormat);
         wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr);
         wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr);
-        va_end(argptr);
 
         wxLogSysErrorHelper(lErrCode);
     }
 }
 
 
         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
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // wxLog class implementation
 // ----------------------------------------------------------------------------
@@ -422,7 +460,10 @@ wxLogStderr::wxLogStderr(FILE *fp)
         m_fp = 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"
 
 #ifndef __MetroNubUtils__
 #include "MetroNubUtils.h"
@@ -605,7 +646,9 @@ OSErr ClearWatchPoint (WatchPointIDT watchPointID)
        }
 #endif
 
        }
 #endif
 
-#endif
+#endif // !TARGET_API_MAC_CARBON
+
+#endif // defined(__WXMAC__) && !defined(__DARWIN__) && (__MWERKS__ > 0x5300)
 
 void wxLogStderr::DoLogString(const wxChar *szString, time_t WXUNUSED(t))
 {
 
 void wxLogStderr::DoLogString(const wxChar *szString, time_t WXUNUSED(t))
 {
@@ -631,11 +674,15 @@ void wxLogStderr::DoLogString(const wxChar *szString, time_t WXUNUSED(t))
 
     Boolean running = false ;
 
 
     Boolean running = false ;
 
+#if !TARGET_API_MAC_CARBON && (__MWERKS__ > 0x5300)
+
     if ( IsMWDebuggerRunning() && AmIBeingMWDebugged() )
     {
         running = true ;
     }
 
     if ( IsMWDebuggerRunning() && AmIBeingMWDebugged() )
     {
         running = true ;
     }
 
+#endif
+
     if (running)
     {
 #ifdef __powerc
     if (running)
     {
 #ifdef __powerc