From 04b4febd6b06c093969595dbf265e3ca0532d5b9 Mon Sep 17 00:00:00 2001 From: Alexander Golubev Date: Mon, 26 Aug 2013 21:45:42 +0400 Subject: [PATCH] kdebug: add default message printing destinations (cherry picked from commit 5354555b1bf1e5c98cf97480cb19c2dcc5f40027) --- kdecore/kdebug.cpp | 41 ++++++++++----- kdecore/kdebugrc | 121 +++++---------------------------------------- 2 files changed, 41 insertions(+), 121 deletions(-) diff --git a/kdecore/kdebug.cpp b/kdecore/kdebug.cpp index 90e94f1b8..17cb95842 100644 --- a/kdecore/kdebug.cpp +++ b/kdecore/kdebug.cpp @@ -222,14 +222,16 @@ static void kDebugBackend( unsigned short nLevel, unsigned int nArea, const char kDebug_data->aAreaName = KGlobal::instance()->instanceName(); } - if (kDebug_data->config && kDebug_data->oldarea != nArea) { - kDebug_data->config->setGroup( TQString::number(static_cast(nArea)) ); + if ( kDebug_data->oldarea != nArea ) { kDebug_data->oldarea = nArea; - if ( nArea > 0 && KGlobal::_instance ) - kDebug_data->aAreaName = getDescrFromNum(nArea); - if ((nArea == 0) || kDebug_data->aAreaName.isEmpty()) - if ( KGlobal::_instance ) + if( KGlobal::_instance ) { + if ( nArea > 0 ) { + kDebug_data->aAreaName = getDescrFromNum(nArea); + } + if ( nArea == 0 || kDebug_data->aAreaName.isEmpty() ) { kDebug_data->aAreaName = KGlobal::instance()->instanceName(); + } + } } int nPriority = 0; @@ -249,7 +251,7 @@ static void kDebugBackend( unsigned short nLevel, unsigned int nArea, const char key = "WarnOutput"; aCaption = "Warning"; nPriority = LOG_WARNING; - break; + break; case KDEBUG_FATAL: key = "FatalOutput"; aCaption = "Fatal Error"; @@ -264,15 +266,30 @@ static void kDebugBackend( unsigned short nLevel, unsigned int nArea, const char break; } - // if no output mode is specified default to no debug output - short nOutput = kDebug_data->config ? kDebug_data->config->readNumEntry(key, 4) : 4; + short nOutput = -1; + if ( kDebug_data->config ) { + kDebug_data->config->setGroup( TQString::number(static_cast(nArea)) ); + nOutput = kDebug_data->config->readNumEntry(key, -1); + if( nOutput == -1 ) { + kDebug_data->config->setGroup( TQString::fromAscii("Default") ); + nOutput = kDebug_data->config->readNumEntry(key, -1); + } + } + // if no output mode is specified default to no stderr output + // NOTE: don't set this to 4 (no output) because in that case you won't be + // able to get any output from applications which don't create + // KApplication objects. + if ( nOutput == -1 ) { + nOutput = 2; + } // If the application doesn't have a TQApplication object it can't use - // a messagebox. - if (!kapp && (nOutput == 1)) + // a messagebox, as well as in case of GUI is disabled. + if ( nOutput == 1 && ( !kapp || !kapp->guiEnabled()) ) { nOutput = 2; - else if ( nOutput == 4 && nLevel != KDEBUG_FATAL ) + } else if ( nOutput == 4 && nLevel != KDEBUG_FATAL ) { return; + } const int BUFSIZE = 4096; char buf[BUFSIZE]; diff --git a/kdecore/kdebugrc b/kdecore/kdebugrc index 58b09ae7a..1ba0aad87 100644 --- a/kdecore/kdebugrc +++ b/kdecore/kdebugrc @@ -19,7 +19,16 @@ # For file output you can give a filename by *Filename= # otherwise kdebug.dbg in the current directory is used. # -# ekzample: +# the Default section sets the destination there all output goes to unless +# there will be explicitly specefied in apropriate area-number section. + +[Default] +FatalOutput=1 +ErrorOutput=2 +WarnOutput=2 +InfoOutput=4 + +# Example: # # For the debug area 100 you want output of debug messages # to a file /var/log/dbg.log and error messages as message boxes. @@ -31,112 +40,6 @@ # ErrorOutput=1 # AbortFatal=1 # - # KAccel debug info off -[125] -InfoOutput=4 - -# KCheckAccel debug info off -[131] -InfoOutput=4 - -# KAction debug info off -[129] -InfoOutput=4 - -# KStartupInfo debug info off -[172] -InfoOutput=4 - -# KLocale debug info off -[173] -InfoOutput=4 - -# KMainWindow debug info off -[200] -InfoOutput=4 - -# KFile debug info off -[250] -InfoOutput=4 - -# KIconloader debug info off -[264] -InfoOutput=4 - -# KSpell debug info off -[750] -InfoOutput=4 - -# KPart's mainwindow info off -[1001] -InfoOutput=4 - -# KPart's factory info off -[1002] -InfoOutput=4 - -# KDesktop icons -[1214] -InfoOutput=4 - -# KHotKeys -[1217] -InfoOutput=4 - -# KMail -[5006] -InfoOutput=4 - -# KitchenSync (Syncing Algorithm) -[5250] -InfoOutput=4 - -# calendarsystem debug info off -[5400] -InfoOutput=4 - -# kabc/vcard -[5710] -InfoOutput=4 - -# korganizer (verbose) -[5855] -InfoOutput=4 - -# korgac (check) -[5891] -InfoOutput=4 - -# kalarmd check -[5901] -InfoOutput=4 - -# kio_http_debug debug info off -[7113] -InfoOutput=4 - -# kbzip2filter's debug info off -[7118] -InfoOutput=4 - -# kio_nntp debug info off -[7114] -InfoOutput=4 - -# KRun debug info off -[7010] -InfoOutput=4 - -# KMimeMagic debug info off -[7018] -InfoOutput=4 - -# KGame debug info off -[11001] -InfoOutput=4 - -# KOStore debug info off -[30002] -InfoOutput=4 - +# [125] +# InfoOutput=4