]> git.saurik.com Git - wxWidgets.git/commitdiff
deprecate integer trace masks and don't define the methods related to them if WXWIN_C...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 22 Mar 2009 16:00:37 +0000 (16:00 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 22 Mar 2009 16:00:37 +0000 (16:00 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59732 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/log.h
interface/wx/log.h
src/common/log.cpp

index e7d2b6cabce5b38610c8ea8381d0d877188cb2ee..bdebce4f9887933350a3b4703f2c5da36245ade3 100644 (file)
 #include "wx/defs.h"
 
 // ----------------------------------------------------------------------------
 #include "wx/defs.h"
 
 // ----------------------------------------------------------------------------
-// common constants for use in wxUSE_LOG/!wxUSE_LOG
+// types
 // ----------------------------------------------------------------------------
 
 // ----------------------------------------------------------------------------
 
-// the trace masks have been superceded by symbolic trace constants, they're
-// for compatibility only andwill be removed soon - do NOT use them
-
-// meaning of different bits of the trace mask (which allows selectively
-// enable/disable some trace messages)
-#define wxTraceMemAlloc 0x0001  // trace memory allocation (new/delete)
-#define wxTraceMessages 0x0002  // trace window messages/X callbacks
-#define wxTraceResAlloc 0x0004  // trace GDI resource allocation
-#define wxTraceRefCount 0x0008  // trace various ref counting operations
+// NB: this is needed even if wxUSE_LOG == 0
+typedef unsigned long wxLogLevel;
 
 
-#ifdef  __WXMSW__
-    #define wxTraceOleCalls 0x0100  // OLE interface calls
-#endif
+// the trace masks have been superseded by symbolic trace constants, they're
+// for compatibility only and will be removed soon - do NOT use them
+#if WXWIN_COMPATIBILITY_2_8
+    #define wxTraceMemAlloc 0x0001  // trace memory allocation (new/delete)
+    #define wxTraceMessages 0x0002  // trace window messages/X callbacks
+    #define wxTraceResAlloc 0x0004  // trace GDI resource allocation
+    #define wxTraceRefCount 0x0008  // trace various ref counting operations
 
 
-// ----------------------------------------------------------------------------
-// types
-// ----------------------------------------------------------------------------
+    #ifdef  __WXMSW__
+        #define wxTraceOleCalls 0x0100  // OLE interface calls
+    #endif
 
 
-// NB: these types are needed even if wxUSE_LOG == 0
-typedef unsigned long wxTraceMask;
-typedef unsigned long wxLogLevel;
+    typedef unsigned long wxTraceMask;
+#endif // WXWIN_COMPATIBILITY_2_8
 
 // ----------------------------------------------------------------------------
 // headers
 
 // ----------------------------------------------------------------------------
 // headers
@@ -191,9 +187,6 @@ public:
     // gets duplicate counting status
     static bool GetRepetitionCounting() { return ms_bRepetCounting; }
 
     // gets duplicate counting status
     static bool GetRepetitionCounting() { return ms_bRepetCounting; }
 
-    // trace mask (see wxTraceXXX constants for details)
-    static void SetTraceMask(wxTraceMask ulMask) { ms_ulTraceMask = ulMask; }
-
     // add string trace mask
     static void AddTraceMask(const wxString& str);
 
     // add string trace mask
     static void AddTraceMask(const wxString& str);
 
@@ -221,9 +214,6 @@ public:
     // gets the verbose status
     static bool GetVerbose() { return ms_bVerbose; }
 
     // gets the verbose status
     static bool GetVerbose() { return ms_bVerbose; }
 
-    // get trace mask
-    static wxTraceMask GetTraceMask() { return ms_ulTraceMask; }
-
     // is this trace mask in the list?
     static bool IsAllowedTraceMask(const wxString& mask);
 
     // is this trace mask in the list?
     static bool IsAllowedTraceMask(const wxString& mask);
 
@@ -260,6 +250,14 @@ public:
     wxDEPRECATED( static wxChar *SetLogBuffer(wxChar *buf, size_t size = 0) );
 #endif
 
     wxDEPRECATED( static wxChar *SetLogBuffer(wxChar *buf, size_t size = 0) );
 #endif
 
+    // don't use integer masks any more, use string trace masks instead
+#if WXWIN_COMPATIBILITY_2_8
+    wxDEPRECATED_INLINE( static void SetTraceMask(wxTraceMask ulMask),
+        ms_ulTraceMask = ulMask; )
+    wxDEPRECATED_BUT_USED_INTERNALLY_INLINE( static wxTraceMask GetTraceMask(),
+        return ms_ulTraceMask; )
+#endif // WXWIN_COMPATIBILITY_2_8
+
 protected:
     // the logging functions that can be overridden
 
 protected:
     // the logging functions that can be overridden
 
@@ -343,8 +341,12 @@ private:
     // disabled
     static wxString    ms_timestamp;
 
     // disabled
     static wxString    ms_timestamp;
 
+#if WXWIN_COMPATIBILITY_2_8
     static wxTraceMask ms_ulTraceMask;   // controls wxLogTrace behaviour
     static wxTraceMask ms_ulTraceMask;   // controls wxLogTrace behaviour
-    static wxArrayString ms_aTraceMasks; // more powerful filter for wxLogTrace
+#endif // WXWIN_COMPATIBILITY_2_8
+
+    // currently enabled trace masks
+    static wxArrayString ms_aTraceMasks;
 };
 
 // ----------------------------------------------------------------------------
 };
 
 // ----------------------------------------------------------------------------
@@ -740,7 +742,9 @@ DECLARE_LOG_FUNCTION2(SysError, unsigned long, lErrCode);
     // and this one does nothing if all of level bits are not set in
     // wxLog::GetActive()->GetTraceMask() -- it's deprecated in favour of
     // string identifiers
     // and this one does nothing if all of level bits are not set in
     // wxLog::GetActive()->GetTraceMask() -- it's deprecated in favour of
     // string identifiers
+#if WXWIN_COMPATIBILITY_2_8
     DECLARE_LOG_FUNCTION2(Trace, wxTraceMask, mask);
     DECLARE_LOG_FUNCTION2(Trace, wxTraceMask, mask);
+#endif // wxDEBUG_LEVEL
 #ifdef __WATCOMC__
     // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
     DECLARE_LOG_FUNCTION2(Trace, int, mask);
 #ifdef __WATCOMC__
     // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
     DECLARE_LOG_FUNCTION2(Trace, int, mask);
index 34cbf28abbf681f38222b22859790cc058d2b4de..e810b5ee2a16f99acd0eb4c956bec49032340c08 100644 (file)
@@ -27,11 +27,6 @@ enum wxLogLevelValues
     wxLOG_Max = 10000
 };
 
     wxLOG_Max = 10000
 };
 
-/**
-    The type used for trace masks.
-*/
-typedef unsigned long wxTraceMask;
-
 /**
     The type used to specify a log level.
 
 /**
     The type used to specify a log level.
 
@@ -613,24 +608,11 @@ public:
     but may be activated, for example, in order to help the user find some program
     problem.
 
     but may be activated, for example, in order to help the user find some program
     problem.
 
-    As for the (real) trace messages, their handling depends on the settings of
-    the (application global) @e trace mask which can either be specified using
-    SetTraceMask(), GetTraceMask() and wxLogTrace() which takes an integer mask
-    or using AddTraceMask() for string trace masks.
+    As for the (real) trace messages, their handling depends on the currently
+    enabled trace masks: if AddTraceMask() was called for the mask of the given
+    message, it will be logged, otherwise nothing happens.
 
 
-    The difference between bit-wise and string trace masks is that a message using
-    integer trace mask will only be logged if all bits of the mask are set in the
-    current mask while a message using string mask will be logged simply if the
-    mask had been added before to the list of allowed ones.
     For example,
     For example,
-
-    @code
-    wxLogTrace( wxTraceRefCount|wxTraceOleCalls, "Active object ref count: %d", nRef );
-    @endcode
-
-    will do something only if the current trace mask contains both @c wxTraceRefCount
-    and @c wxTraceOle, but:
-
     @code
     wxLogTrace( wxTRACE_OleCalls, "IFoo::Bar() called" );
     @endcode
     @code
     wxLogTrace( wxTRACE_OleCalls, "IFoo::Bar() called" );
     @endcode
@@ -641,11 +623,6 @@ public:
     wxLog::AddTraceMask( wxTRACE_OleCalls);
     @endcode
 
     wxLog::AddTraceMask( wxTRACE_OleCalls);
     @endcode
 
-    Using string masks is simpler and allows you to easily add custom ones, so this
-    is the preferred way of working with trace messages. The integer trace mask is
-    kept for compatibility and for additional (but very rarely needed) flexibility
-    only.
-
     The standard trace masks are given in wxLogTrace() documentation.
 
     Finally, the @e wxLog::DoLog() function automatically prepends a time stamp
     The standard trace masks are given in wxLogTrace() documentation.
 
     Finally, the @e wxLog::DoLog() function automatically prepends a time stamp
@@ -766,6 +743,7 @@ public:
     static const wxString& GetTimestamp();
 
     /**
     static const wxString& GetTimestamp();
 
     /**
+        @deprecated
         Returns the current trace mask, see Customization() section for details.
     */
     static wxTraceMask GetTraceMask();
         Returns the current trace mask, see Customization() section for details.
     */
     static wxTraceMask GetTraceMask();
@@ -848,7 +826,8 @@ public:
     static void DisableTimestamp();
 
     /**
     static void DisableTimestamp();
 
     /**
-        Sets the trace mask, see @ref log_derivingyours section for details.
+        @deprecated
+        Sets the trace mask, see @ref log_tracemasks section for details.
     */
     static void SetTraceMask(wxTraceMask mask);
 
     */
     static void SetTraceMask(wxTraceMask mask);
 
@@ -1112,15 +1091,15 @@ void wxVLogError(const char* formatString, va_list argPtr);
     function is that usually there are a lot of trace messages, so it might
     make sense to separate them from other debug messages.
 
     function is that usually there are a lot of trace messages, so it might
     make sense to separate them from other debug messages.
 
-    wxLogDebug(const char*,const char*,...) and
-    wxLogDebug(wxTraceMask,const char*,...) can be used instead if you would
-    like to be able to separate trace messages into different categories which
-    can be enabled or disabled with the static functions provided in wxLog.
+    wxLogTrace(const char*,const char*,...) and can be used instead of
+    wxLogDebug() if you would like to be able to separate trace messages into
+    different categories which can be enabled or disabled with
+    wxLog::AddTraceMask() and wxLog::RemoveTraceMask().
 
     @header{wx/log.h}
 */
 
     @header{wx/log.h}
 */
-void wxLogTrace(const char* formatString, ... );
-void wxVLogTrace(const char* formatString, va_list argPtr);
+void wxLogTrace(const char *mask, const char* formatString, ... );
+void wxVLogTrace(const char *mask, const char* formatString, va_list argPtr);
 //@}
 
 /** @addtogroup group_funcmacro_log */
 //@}
 
 /** @addtogroup group_funcmacro_log */
@@ -1178,7 +1157,7 @@ void wxVLogTrace(const char* mask,
     This version of wxLogTrace() only logs the message if all the bits
     corresponding to the @a mask are set in the wxLog trace mask which can be
     set by calling wxLog::SetTraceMask(). This version is less flexible than
     This version of wxLogTrace() only logs the message if all the bits
     corresponding to the @a mask are set in the wxLog trace mask which can be
     set by calling wxLog::SetTraceMask(). This version is less flexible than
-    wxLogDebug(const char*,const char*,...) because it doesn't allow defining
+    wxLogTrace(const char*,const char*,...) because it doesn't allow defining
     the user trace masks easily. This is why it is deprecated in favour of
     using string trace masks.
 
     the user trace masks easily. This is why it is deprecated in favour of
     using string trace masks.
 
index 558f17e658e680797d926f292f9e90bed66967f7..8b5662d93d4430f5c0013b36aede8afacbebb71c 100644 (file)
@@ -331,6 +331,9 @@ void wxDoLogVerboseUtf8(const char *format, ...)
   }
 #endif // wxUSE_UNICODE_UTF8
 
   }
 #endif // wxUSE_UNICODE_UTF8
 
+// deprecated (but not declared as such because we don't want to complicate
+// DECLARE_LOG_FUNCTION macros even more) overloads for wxTraceMask
+#if WXWIN_COMPATIBILITY_2_8
   void wxVLogTrace(wxTraceMask mask, const wxString& format, va_list argptr)
   {
     // we check that all of mask bits are set in the current mask, so
   void wxVLogTrace(wxTraceMask mask, const wxString& format, va_list argptr)
   {
     // we check that all of mask bits are set in the current mask, so
@@ -361,7 +364,10 @@ void wxDoLogVerboseUtf8(const char *format, ...)
   }
 #endif // wxUSE_UNICODE_UTF8
 
   }
 #endif // wxUSE_UNICODE_UTF8
 
+#endif // WXWIN_COMPATIBILITY_2_8
+
 #ifdef __WATCOMC__
 #ifdef __WATCOMC__
+#if WXWIN_COMPATIBILITY_2_8
   // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
   void wxDoLogTraceWchar(int mask, const wxChar *format, ...)
   {
   // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
   void wxDoLogTraceWchar(int mask, const wxChar *format, ...)
   {
@@ -370,6 +376,7 @@ void wxDoLogVerboseUtf8(const char *format, ...)
     wxVLogTrace(mask, format, argptr);
     va_end(argptr);
   }
     wxVLogTrace(mask, format, argptr);
     va_end(argptr);
   }
+#endif // WXWIN_COMPATIBILITY_2_8
 
   void wxDoLogTraceWchar(const char *mask, const wxChar *format, ...)
   {
 
   void wxDoLogTraceWchar(const char *mask, const wxChar *format, ...)
   {
@@ -387,8 +394,10 @@ void wxDoLogVerboseUtf8(const char *format, ...)
     va_end(argptr);
   }
 
     va_end(argptr);
   }
 
+#if WXWIN_COMPATIBILITY_2_8
   void wxVLogTrace(int mask, const wxString& format, va_list argptr)
     { wxVLogTrace((wxTraceMask)mask, format, argptr); }
   void wxVLogTrace(int mask, const wxString& format, va_list argptr)
     { wxVLogTrace((wxTraceMask)mask, format, argptr); }
+#endif // WXWIN_COMPATIBILITY_2_8
   void wxVLogTrace(const char *mask, const wxString& format, va_list argptr)
     { wxVLogTrace(wxString(mask), format, argptr); }
   void wxVLogTrace(const wchar_t *mask, const wxString& format, va_list argptr)
   void wxVLogTrace(const char *mask, const wxString& format, va_list argptr)
     { wxVLogTrace(wxString(mask), format, argptr); }
   void wxVLogTrace(const wchar_t *mask, const wxString& format, va_list argptr)
@@ -975,7 +984,10 @@ size_t          wxLog::ms_suspendCount = 0;
 
 wxString        wxLog::ms_timestamp(wxS("%X"));  // time only, no date
 
 
 wxString        wxLog::ms_timestamp(wxS("%X"));  // time only, no date
 
+#if WXWIN_COMPATIBILITY_2_8
 wxTraceMask     wxLog::ms_ulTraceMask  = (wxTraceMask)0;
 wxTraceMask     wxLog::ms_ulTraceMask  = (wxTraceMask)0;
+#endif // wxDEBUG_LEVEL
+
 wxArrayString   wxLog::ms_aTraceMasks;
 
 // ----------------------------------------------------------------------------
 wxArrayString   wxLog::ms_aTraceMasks;
 
 // ----------------------------------------------------------------------------