summaryrefslogtreecommitdiffstats
path: root/opensuse/core/tdelibs.old/no-debug-by-default.diff
blob: 5b1440970ec3ae0e0e00bd3289af0bc884171629 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
Index: kdecore/kdebug.cpp
===================================================================
--- kdecore/kdebug.cpp.orig
+++ kdecore/kdebug.cpp
@@ -170,7 +170,7 @@ static KStaticDeleter<kDebugPrivate> pcd
 static KStaticDeleter<KDebugDCOPIface> dcopsd;
 static KDebugDCOPIface* kDebugDCOPIface = 0;
 
-static void kDebugBackend( unsigned short nLevel, unsigned int nArea, const char *data)
+static void kDebugInitBackend(unsigned int nArea)
 {
   if ( !kDebug_data )
   {
@@ -205,40 +205,46 @@ static void kDebugBackend( unsigned shor
       if ( KGlobal::_instance )
         kDebug_data->aAreaName = KGlobal::instance()->instanceName();
   }
+}
 
-  int nPriority = 0;
-  QString aCaption;
-
-    /* Determine output */
+static short kDebugAreaOutput(unsigned short nLevel, unsigned int nArea)
+{
+  kDebugInitBackend (nArea);
 
+  /* Determine output */
   QString key;
   switch( nLevel )
   {
   case KDEBUG_INFO:
       key = "InfoOutput";
-      aCaption = "Info";
-      nPriority = LOG_INFO;
       break;
   case KDEBUG_WARN:
       key = "WarnOutput";
-      aCaption = "Warning";
-      nPriority = LOG_WARNING;
 	break;
   case KDEBUG_FATAL:
       key = "FatalOutput";
-      aCaption = "Fatal Error";
-      nPriority = LOG_CRIT;
       break;
   case KDEBUG_ERROR:
   default:
       /* Programmer error, use "Error" as default */
       key = "ErrorOutput";
-      aCaption = "Error";
-      nPriority = LOG_ERR;
       break;
   }
 
-  short nOutput = kDebug_data->config ? kDebug_data->config->readNumEntry(key, 2) : 2;
+  return kDebug_data->config ? kDebug_data->config->readNumEntry(key, 4) : 4;
+}
+
+
+bool kDebugAreaEnabled(unsigned short nLevel, unsigned int nArea)
+{
+    return kDebugAreaOutput(nLevel, nArea) != 4;
+}
+
+static void kDebugBackend( unsigned short nLevel, unsigned int nArea, const char *data)
+{
+  kDebugInitBackend (nArea);
+
+  short nOutput = kDebugAreaOutput(nLevel, nArea);
 
   // If the application doesn't have a QApplication object it can't use
   // a messagebox.
@@ -247,6 +253,32 @@ static void kDebugBackend( unsigned shor
   else if ( nOutput == 4 && nLevel != KDEBUG_FATAL )
       return;
 
+  int nPriority = 0;
+  QString aCaption;
+  switch( nLevel )
+  {
+  case KDEBUG_INFO:
+      aCaption = "Info";
+      nPriority = LOG_INFO;
+      break;
+  case KDEBUG_WARN:
+      aCaption = "Warning";
+      nPriority = LOG_WARNING;
+	break;
+  case KDEBUG_FATAL:
+      aCaption = "Fatal Error";
+      nPriority = LOG_CRIT;
+      break;
+  case KDEBUG_ERROR:
+  default:
+      /* Programmer error, use "Error" as default */
+      aCaption = "Error";
+      nPriority = LOG_ERR;
+      break;
+  }
+
+
+
   const int BUFSIZE = 4096;
   char buf[BUFSIZE];
   if ( !kDebug_data->aAreaName.isEmpty() ) {
@@ -314,13 +346,25 @@ static void kDebugBackend( unsigned shor
 }
 
 kdbgstream &perror( kdbgstream &s) { return s << QString::fromLocal8Bit(strerror(errno)); }
-kdbgstream kdDebug(int area) { return kdbgstream(area, KDEBUG_INFO); }
-kdbgstream kdDebug(bool cond, int area) { if (cond) return kdbgstream(area, KDEBUG_INFO); else return kdbgstream(0, 0, false); }
+kdbgstream kdDebug(int area) { return kdbgstream(area, KDEBUG_INFO, kDebugAreaEnabled(KDEBUG_INFO, area)); }
+kdbgstream kdDebug(bool cond, int area) { if (cond) return kdbgstream(area, KDEBUG_INFO, kDebugAreaEnabled(KDEBUG_INFO, area)); else return kdbgstream(0, 0, false); }
 
 kdbgstream kdError(int area) { return kdbgstream("ERROR: ", area, KDEBUG_ERROR); }
 kdbgstream kdError(bool cond, int area) { if (cond) return kdbgstream("ERROR: ", area, KDEBUG_ERROR); else return kdbgstream(0,0,false); }
-kdbgstream kdWarning(int area) { return kdbgstream("WARNING: ", area, KDEBUG_WARN); }
-kdbgstream kdWarning(bool cond, int area) { if (cond) return kdbgstream("WARNING: ", area, KDEBUG_WARN); else return kdbgstream(0,0,false); }
+
+kdbgstream kdWarning(int area)
+{
+    return kdbgstream("WARNING: ", area, KDEBUG_WARN, kDebugAreaEnabled(KDEBUG_WARN, area));
+}
+
+kdbgstream kdWarning(bool cond, int area) 
+{
+    if (cond)
+        return kdbgstream("WARNING: ", area, KDEBUG_WARN, kDebugAreaEnabled(KDEBUG_WARN, area));
+    else
+        return kdbgstream(0,0,false);
+}
+
 kdbgstream kdFatal(int area) { return kdbgstream("FATAL: ", area, KDEBUG_FATAL); }
 kdbgstream kdFatal(bool cond, int area) { if (cond) return kdbgstream("FATAL: ", area, KDEBUG_FATAL); else return kdbgstream(0,0,false); }
 
@@ -331,9 +375,10 @@ kdbgstream::kdbgstream(kdbgstream &str)
 }
 
 void kdbgstream::flush() {
-    if (output.isEmpty() || !print)
+    if (output.isEmpty())
 	return;
-    kDebugBackend( level, area, output.local8Bit().data() );
+    if (print)
+        kDebugBackend( level, area, output.local8Bit().data() );
     output = QString::null;
 }
 
@@ -349,7 +394,7 @@ kdbgstream &kdbgstream::form(const char
 }
 
 kdbgstream::~kdbgstream() {
-    if (!output.isEmpty()) {
+    if (print && !output.isEmpty()) {
 	fprintf(stderr, "ASSERT: debug output not ended with \\n\n");
         fprintf(stderr, "%s", kdBacktrace().latin1());
 	*this << "\n";