[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: [PATCH] default output setting for kdebug
From: ralf.habacker () freenet ! de
Date: 2005-05-23 8:14:53
Message-ID: 200505231015.04190.ralf.habacker () freenet ! de
[Download RAW message or body]
Hi,
currently the kDebug support uses hardcoded stderr as default output. The
appended patch adds a configuration entry for choosing a customizable default
output for all not in kdebugrc used kdebug numbers.
Ralf
["09-kdebug-defaultoutput.patch" (text/x-diff)]
Index: kdebug.cpp
===================================================================
--- kdebug.cpp (revision 415431)
+++ kdebug.cpp (working copy)
@@ -153,6 +153,13 @@
KDEBUG_FATAL= 3
};
+enum DebugOutput {
+ KDEBUG_FILE= 0,
+ KDEBUG_MSGBOX= 1,
+ KDEBUG_STDERR= 2, //(shell)
+ KDEBUG_SYSLOG= 3,
+ KDEBUG_OFF= 4
+};
struct kDebugPrivate {
kDebugPrivate() :
@@ -172,6 +179,8 @@
static void kDebugBackend( unsigned short nLevel, unsigned int nArea, const char \
*data) {
+ int defaultOutput = KDEBUG_STDERR;
+
if ( !kDebug_data )
{
pcd.setObject(kDebug_data, new kDebugPrivate());
@@ -196,6 +205,13 @@
kDebug_data->aAreaName = KGlobal::instance()->instanceName();
}
+ if (kDebug_data->config)
+ {
+ kDebug_data->config->setGroup("General");
+ defaultOutput = kDebug_data->config->readNumEntry("DefaultOutput", 2);
+ kDebug_data->config->setGroup("0");
+ }
+
if (kDebug_data->config && kDebug_data->oldarea != nArea) {
kDebug_data->config->setGroup( QString::number(static_cast<int>(nArea)) );
kDebug_data->oldarea = nArea;
@@ -238,13 +254,13 @@
break;
}
- short nOutput = kDebug_data->config ? kDebug_data->config->readNumEntry(key, 2) : \
2; + short nOutput = kDebug_data->config ? kDebug_data->config->readNumEntry(key, \
defaultOutput) : defaultOutput;
// If the application doesn't have a QApplication object it can't use
// a messagebox.
- if (!kapp && (nOutput == 1))
- nOutput = 2;
- else if ( nOutput == 4 && nLevel != KDEBUG_FATAL )
+ if (!kapp && (nOutput == KDEBUG_MSGBOX))
+ nOutput = defaultOutput;
+ else if ( nOutput == KDEBUG_OFF && nLevel != KDEBUG_FATAL )
return;
const int BUFSIZE = 4096;
@@ -261,7 +277,7 @@
// Output
switch( nOutput )
{
- case 0: // File
+ case KDEBUG_FILE:
{
const char* aKey;
switch( nLevel )
@@ -286,7 +302,7 @@
aOutputFile.close();
break;
}
- case 1: // Message Box
+ case KDEBUG_MSGBOX:
{
// Since we are in kdecore here, we cannot use KMsgBox and use
// QMessageBox instead
@@ -295,12 +311,12 @@
QMessageBox::warning( 0L, aCaption, data, i18n("&OK") );
break;
}
- case 2: // Shell
+ case KDEBUG_STDERR: // Shell
{
write( 2, buf, strlen( buf ) ); //fputs( buf, stderr );
break;
}
- case 3: // syslog
+ case KDEBUG_SYSLOG: // syslog
{
syslog( nPriority, "%s", buf);
break;
Index: kdebugrc
===================================================================
--- kdebugrc (revision 415431)
+++ kdebugrc (working copy)
@@ -31,6 +31,8 @@
# ErrorOutput=1
# AbortFatal=1
#
+[General]
+DefaultOutput=2
# KAccel debug info off
[125]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic