From 89d62794e4595794191c7c9fcda6fd9f6b016664 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 23 Jul 2009 13:40:44 +0000 Subject: [PATCH] Implement wxVLogTrace() accidentally removed by recent changes. 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 | 15 +++++++++++++++ tests/log/logtest.cpp | 24 +++++++++++++++++++++--- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/include/wx/log.h b/include/wx/log.h index f56b5921ed..7e0912c0da 100644 --- a/include/wx/log.h +++ b/include/wx/log.h @@ -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() diff --git a/tests/log/logtest.cpp b/tests/log/logtest.cpp index 0334bc6d63..644a18f89f 100644 --- a/tests/log/logtest.cpp +++ b/tests/log/logtest.cpp @@ -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) ); } -- 2.47.2