summaryrefslogtreecommitdiff
path: root/libopie2
Side-by-side diff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/odebug.cpp12
-rw-r--r--libopie2/opiecore/odebug.h9
2 files changed, 14 insertions, 7 deletions
diff --git a/libopie2/opiecore/odebug.cpp b/libopie2/opiecore/odebug.cpp
index 3bffdd0..d8dfe26 100644
--- a/libopie2/opiecore/odebug.cpp
+++ b/libopie2/opiecore/odebug.cpp
@@ -124,59 +124,59 @@ void DebugBackend::debug(unsigned short level, unsigned int, const QString& data
int priority = 0;
QString caption;
QString lev;
switch( level )
{
case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break;
case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break;
case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break;
default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." );
case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break;
}
if (!oApp && (m_outp == 1)) {
qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" );
m_outp = 2; // need an application object to use MsgBox
}
// gcc 2.9x is dumb and sucks... can you hear it?
//QString areaName = (oApp) ? oApp->appName() : "<unknown>";
QString areaName;
if ( oApp ) areaName = oApp->appName();
else areaName = "<unknown>";
switch( m_outp ) {
- case -1: // ignore
+ case ODEBUG_IGNORE:
return;
- case 0: // File
+ case ODEBUG_FILE:
return debugFile( areaName, data );
- case 1: // Message Box
+ case ODEBUG_MSGBOX:
return debugMsgB( areaName, data );
- case 2:
+ case ODEBUG_STDERR:
return debugShel( areaName,data );
- case 3: // syslog
+ case ODEBUG_SYSLOG:
return debugSysl( priority, data );
- case 4: // socket
+ case ODEBUG_SOCKET:
return debugSock( areaName, data );
}
}
inline void DebugBackend::debugFile(const QString& area, const QString& data) {
/* something went wrong with the file don't bother.. */
if ( m_opened && !m_file )
return;
else if ( !m_opened ) {
m_opened = true;
m_file = new QFile( OGlobalSettings::debugOutput() );
if (!m_file->open( IO_WriteOnly | IO_Append ) ) {
delete m_file; m_file = 0;
qDebug( "ODebug: can't write to file '%s' (%s)", (const char*)OGlobalSettings::debugOutput(),
strerror(errno) );
return;
}
}
/* go to end of file */
m_file->at( m_file->size() );
QCString li = line( area, data );
m_file->writeBlock(li.data(), li.length() );
}
diff --git a/libopie2/opiecore/odebug.h b/libopie2/opiecore/odebug.h
index 3851a41..21a6c26 100644
--- a/libopie2/opiecore/odebug.h
+++ b/libopie2/opiecore/odebug.h
@@ -46,48 +46,55 @@ class QRegion;
class QStringList;
class QColor;
class QBrush;
namespace Opie {
namespace Core {
class odbgstream;
class ondbgstream;
#ifdef __GNUC__
#define o_funcinfo "[" << __PRETTY_FUNCTION__ << "] "
#else
#define o_funcinfo "[" << __FILE__ << ":" << __LINE__ << "] "
#endif
#define o_lineinfo "[" << __FILE__ << ":" << __LINE__ << "] "
#define owarn Opie::Core::odWarning()
#define oerr Opie::Core::odError()
#define odebug Opie::Core::odDebug()
#define ofatal Opie::Core::odFatal()
#define oendl "\n"
+const int ODEBUG_IGNORE = -1;
+const int ODEBUG_FILE = 0;
+const int ODEBUG_MSGBOX = 1;
+const int ODEBUG_STDERR = 2;
+const int ODEBUG_SYSLOG = 3;
+const int ODEBUG_SOCKET = 4;
+
class odbgstreamprivate;
/**
* odbgstream is a text stream that allows you to print debug messages.
* Using the overloaded "<<" operator you can send messages. Usually
* you do not create the odbgstream yourself, but use @ref odDebug() (odebug)
* @ref odWarning() (owarn), @ref odError() (oerr) or @ref odFatal (ofatal) to obtain one.
*
* Example:
* <pre>
* int i = 5;
* odebug << "The value of i is " << i << oendl;
* </pre>
* @see odbgstream
*/
/*======================================================================================
* odbgstream
*======================================================================================*/
class odbgstream
{
public:
/**
* @internal
@@ -376,49 +383,49 @@ class ondbgstream {
* @return this stream
*/
ondbgstream& operator<<(unsigned long) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream& operator << (QWidget*) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream &form(const char *, ...) { return *this; }
ondbgstream& operator<<( const QDateTime& ) { return *this; }
ondbgstream& operator<<( const QDate& ) { return *this; }
ondbgstream& operator<<( const QTime& ) { return *this; }
ondbgstream& operator<<( const QPoint & ) { return *this; }
ondbgstream& operator<<( const QSize & ) { return *this; }
ondbgstream& operator<<( const QRect & ) { return *this; }
ondbgstream& operator<<( const QRegion & ) { return *this; }
ondbgstream& operator<<( const QStringList & ) { return *this; }
ondbgstream& operator<<( const QColor & ) { return *this; }
ondbgstream& operator<<( const QBrush & ) { return *this; }
-
+
private:
class Private;
Private *d;
};
/*======================================================================================
* related functions
*======================================================================================*/
/**
* Does nothing.
* @param a stream
* @return the given @p s
*/
inline ondbgstream& endl( ondbgstream & s) { return s; }
/**
* Does nothing.
* @param a stream
* @return the given @p s
*/
inline ondbgstream& flush( ondbgstream & s) { return s; }
inline ondbgstream& perror( ondbgstream & s) { return s; }
/**