]> git.saurik.com Git - wxWidgets.git/commitdiff
Implement wxVLogTrace() accidentally removed by recent changes.
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 23 Jul 2009 13:40:44 +0000 (13:40 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 23 Jul 2009 13:40:44 +0000 (13:40 +0000)
Also change the unit test to test wxVLogTrace() as well as wxLogTrace.

Closes #11011.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61505 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/log.h
tests/log/logtest.cpp

index f56b5921edf3ef8311891f1f1c982e070698e48f..7e0912c0da1d8e3a0b46e53378d98d8a288202e9 100644 (file)
@@ -901,6 +901,16 @@ public:
         LogV(format, argptr);
     }
 
+    void LogVTrace(const wxString& mask, const wxString& format, va_list argptr)
+    {
+        if ( !wxLog::IsAllowedTraceMask(mask) )
+            return;
+
+        Store(wxLOG_KEY_TRACE_MASK, mask);
+
+        LogV(format, argptr);
+    }
+
 
     // vararg functions used by wxLogXXX():
 
@@ -1488,6 +1498,11 @@ public:
         {}                                                                    \
         else                                                                  \
             wxMAKE_LOGGER(Trace).LogTrace
+    #define wxVLogTrace                                                       \
+        if ( !wxLog::IsLevelEnabled(wxLOG_Trace, wxLOG_COMPONENT) )           \
+        {}                                                                    \
+        else                                                                  \
+            wxMAKE_LOGGER(Trace).LogVTrace
 #else  // !wxUSE_LOG_TRACE
     #define wxVLogTrace(mask, fmt, valist) wxLogNop()
 
index 0334bc6d633dad225fbd8410dcf25c646e0b93ee..644a18f89f189ca701090d67770e32e50b3fa90b 100644 (file)
@@ -273,22 +273,40 @@ void LogTestCase::Component()
 
 #if wxDEBUG_LEVEL
 
+namespace
+{
+
+const char *TEST_MASK = "test";
+
+// this is a test vararg function (a real one, not a variadic-template-like as
+// wxVLogTrace(), so care should be taken with its arguments)
+void TraceTest(const char *format, ...)
+{
+    va_list argptr;
+    va_start(argptr, format);
+    wxVLogTrace(TEST_MASK, format, argptr);
+    va_end(argptr);
+}
+
+} // anonymous namespace
+
 void LogTestCase::Trace()
 {
-    static const char *TEST_MASK = "test";
+    // we use wxLogTrace() or wxVLogTrace() from inside TraceTest()
+    // interchangeably here, it shouldn't make any difference
 
     wxLogTrace(TEST_MASK, "Not shown");
     CPPUNIT_ASSERT_EQUAL( "", m_log->GetLog(wxLOG_Trace) );
 
     wxLog::AddTraceMask(TEST_MASK);
-    wxLogTrace(TEST_MASK, "Shown");
+    TraceTest("Shown");
     CPPUNIT_ASSERT_EQUAL( wxString::Format("(%s) Shown", TEST_MASK),
                           m_log->GetLog(wxLOG_Trace) );
 
     wxLog::RemoveTraceMask(TEST_MASK);
     m_log->Clear();
 
-    wxLogTrace(TEST_MASK, "Not shown again");
+    TraceTest("Not shown again");
     CPPUNIT_ASSERT_EQUAL( "", m_log->GetLog(wxLOG_Trace) );
 }