[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    KDE/kdelibs/kdecore
From:       David Faure <faure () kde ! org>
Date:       2009-08-17 18:22:48
Message-ID: 1250533368.959513.25131.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1012502 by dfaure:

Add a "bool enable" to registerArea so that verbose debug areas can be disabled by default
This BIC, but the method is new in trunk, so no big deal, just more recompilation.
CCMAIL: kde-core-devel@kde.org


 M  +5 -5      io/kdebug.cpp  
 M  +3 -1      io/kdebug.h  
 M  +10 -0     tests/kdebug_unittest.cpp  
 M  +1 -0      tests/kdebug_unittest.h  


--- trunk/KDE/kdelibs/kdecore/io/kdebug.cpp #1012501:1012502
@@ -401,7 +401,7 @@
             static bool s_firstDebugFromApplication = true;
             if (s_firstDebugFromApplication) {
                 s_firstDebugFromApplication = false;
-                writeGroupForNamedArea(it->name);
+                writeGroupForNamedArea(it->name, true);
             }
         }
 
@@ -614,7 +614,7 @@
         return printHeader(s, areaName, debugFile, line, funcinfo, type, colored);
     }
 
-    void writeGroupForNamedArea(const QByteArray& areaName)
+    void writeGroupForNamedArea(const QByteArray& areaName, bool enabled)
     {
         // Ensure that this area name appears in kdebugrc, so that users (via kdebugdialog)
         // can turn it off.
@@ -623,7 +623,7 @@
             KConfigGroup cg(cfgObj, QString::fromUtf8(areaName));
             const QString key = QString::fromLatin1("InfoOutput");
             if (!cg.hasKey(key)) {
-                cg.writeEntry(key, int(KDebugPrivate::QtOutput));
+                cg.writeEntry(key, int(enabled ? KDebugPrivate::QtOutput : KDebugPrivate::NoOutput));
             }
         }
     }
@@ -770,7 +770,7 @@
     return KDebug::hasNullOutput(type, area);
 }
 
-int KDebug::registerArea(const QByteArray& areaName)
+int KDebug::registerArea(const QByteArray& areaName, bool enabled)
 {
     // TODO for optimization: static int s_lastAreaNumber = 1;
     KDebugPrivate* d = kDebug_data;
@@ -782,7 +782,7 @@
     KDebugPrivate::Area areaData;
     areaData.name = areaName;
     d->cache.insert(areaNumber, areaData);
-    d->writeGroupForNamedArea(areaName);
+    d->writeGroupForNamedArea(areaName, enabled);
     return areaNumber;
 }
 
--- trunk/KDE/kdelibs/kdecore/io/kdebug.h #1012501:1012502
@@ -254,6 +254,8 @@
      * @since 4.4
      * Register a debug area dynamically.
      * @param areaName the name of the area
+     * @param enabled whether debug output should be enabled by default
+     * (users can override this in kdebugdialog or with DisableAll=true in kdebugrc)
      * @return the area code that was allocated for this area
      *
      * Typical usage:
@@ -270,7 +272,7 @@
      * declare it in one file without static, and use "extern int debugArea();"
      * in other files (with a better name for the function of course).
      */
-    static KDECORE_EXPORT int registerArea(const QByteArray& areaName);
+    static KDECORE_EXPORT int registerArea(const QByteArray& areaName, bool enabled = true);
 };
 
 
--- trunk/KDE/kdelibs/kdecore/tests/kdebug_unittest.cpp #1012501:1012502
@@ -160,6 +160,16 @@
     compareLines(expected, "myarea.dbg");
 }
 
+void KDebugTest::testDisabledDynamicArea()
+{
+    const int verboseArea = KDebug::registerArea("verbosearea", false);
+    QVERIFY(verboseArea > 0);
+    kClearDebugConfig(); // force a sync() of KDebug's own kdebugrc so that it gets written out
+    KConfig config("kdebugrc");
+    QVERIFY(config.hasGroup("verbosearea"));
+    kDebug(verboseArea) << "TEST DEBUG using verboseArea" << verboseArea;
+}
+
 #include <QThreadPool>
 #include <qtconcurrentrun.h>
 
--- trunk/KDE/kdelibs/kdecore/tests/kdebug_unittest.h #1012501:1012502
@@ -34,6 +34,7 @@
     void testDebugToFile();
     void testDisableArea();
     void testDynamicArea();
+    void testDisabledDynamicArea();
     void testMultipleThreads();
 
 private:
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic