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

List:       kde-core-devel
Subject:    Re: Filterin the debug output
From:       Thiago Macieira <thiago () kde ! org>
Date:       2007-10-23 11:37:45
Message-ID: 200710231337.45539.thiago () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


Em Tuesday 23 October 2007 13:22:34 Boudewijn Rempt escreveu:
> On Tue, 23 Oct 2007, Boudewijn Rempt wrote:
> > Indeed. And making non-existing debug areas give no output by default
> > would make sure people know when they are using them.
>
> Something like
>
> Index: kdebug.cpp
> ===================================================================
> --- kdebug.cpp	(revision 728385)
> +++ kdebug.cpp	(working copy)
> @@ -314,7 +314,7 @@
>          }
>
>          KConfigGroup cg(config, QString::number(area));
> -        int mode = cg.readEntry(key, 2);
> +        int mode = cg.readEntry(key, 4);
>          return OutputMode(mode);
>      }
>
>
> Should work, I guess.

I almost sent that patch, but that doesn't solve the problem. It'll simply 
make the default for ALL areas be NoOutput. That's not what we want.

The attached patch does it (untested, but compiles).

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

["kdebug-no-output-for-unknown-areas.patch" (text/x-diff)]

diff --git a/kdecore/io/kdebug.cpp b/kdecore/io/kdebug.cpp
index 36d5ecc..1b9f823 100644
--- a/kdecore/io/kdebug.cpp
+++ b/kdecore/io/kdebug.cpp
@@ -234,12 +234,14 @@ struct KDebugPrivate
     {
         cache.clear();
 
-        Area &areaData = cache[0];
-        areaData.clear(QtOutput);
+        {
+            Area &areaData = cache[0];
+            areaData.clear(QtOutput);
 
-        //AB: this is necessary here, otherwise all output with area 0 won't be
-        //prefixed with anything, unless something with area != 0 is called before
-        areaData.name = KGlobal::mainComponent().componentName();
+            //AB: this is necessary here, otherwise all output with area 0 won't be
+            //prefixed with anything, unless something with area != 0 is called before
+            areaData.name = KGlobal::mainComponent().componentName();
+        }
 
         QString filename(KStandardDirs::locate("config", QLatin1String("kdebug.areas")));
         if (filename.isEmpty()) {
@@ -285,6 +287,11 @@ struct KDebugPrivate
             cache.insert(number, areaData);
         }
         file.close();
+
+        // Add the "invalid area"
+        Area invalidArea;
+        invalidArea.clear(NoOutput);
+        cache.insert(-1, invalidArea);
     }
 
     inline int level(QtMsgType type)
@@ -361,7 +368,7 @@ struct KDebugPrivate
 
         if (!cache.contains(num))
             // unknown area
-            return cache.find(0);
+            return cache.find(-1);
 
         int l = level(type);
         Cache::Iterator it = cache.find(num);

["signature.asc" (application/pgp-signature)]

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

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