-rw-r--r-- | libopie2/opiecore/odebug.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libopie2/opiecore/odebug.cpp b/libopie2/opiecore/odebug.cpp index b4eaf2d..b2a37bc 100644 --- a/libopie2/opiecore/odebug.cpp +++ b/libopie2/opiecore/odebug.cpp | |||
@@ -95,65 +95,69 @@ enum DebugLevels { | |||
95 | 95 | ||
96 | /*====================================================================================== | 96 | /*====================================================================================== |
97 | * the main debug function | 97 | * the main debug function |
98 | *======================================================================================*/ | 98 | *======================================================================================*/ |
99 | 99 | ||
100 | static void oDebugBackend( unsigned short level, unsigned int area, const char *data) | 100 | static void oDebugBackend( unsigned short level, unsigned int area, const char *data) |
101 | { | 101 | { |
102 | //qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data ); | 102 | //qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data ); |
103 | 103 | ||
104 | // ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an | 104 | // ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an |
105 | // ML: example use. I think it's not necessary to implement such a strategy here. | 105 | // ML: example use. I think it's not necessary to implement such a strategy here. |
106 | // ML: Comments? | 106 | // ML: Comments? |
107 | 107 | ||
108 | int priority = 0; | 108 | int priority = 0; |
109 | QString caption; | 109 | QString caption; |
110 | QString lev; | 110 | QString lev; |
111 | switch( level ) | 111 | switch( level ) |
112 | { | 112 | { |
113 | case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break; | 113 | case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break; |
114 | case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break; | 114 | case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break; |
115 | case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break; | 115 | case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break; |
116 | default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." ); | 116 | default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." ); |
117 | case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break; | 117 | case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break; |
118 | } | 118 | } |
119 | 119 | ||
120 | short output = OGlobalSettings::debugMode(); | 120 | short output = OGlobalSettings::debugMode(); |
121 | if (!oApp && (output == 1)) | 121 | if (!oApp && (output == 1)) |
122 | { | 122 | { |
123 | qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" ); | 123 | qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" ); |
124 | output = 2; // need an application object to use MsgBox | 124 | output = 2; // need an application object to use MsgBox |
125 | } | 125 | } |
126 | 126 | ||
127 | QString areaName = (oApp) ? oApp->appName() : "<unknown>"; | 127 | // gcc 2.9x is dumb and sucks... can you hear it? |
128 | //QString areaName = (oApp) ? oApp->appName() : "<unknown>"; | ||
129 | QString areaName; | ||
130 | if ( oApp ) areaName = oApp->appName(); | ||
131 | else areaName = "<unknown>"; | ||
128 | 132 | ||
129 | // Output | 133 | // Output |
130 | switch( output ) | 134 | switch( output ) |
131 | { | 135 | { |
132 | case -1: // ignore | 136 | case -1: // ignore |
133 | { | 137 | { |
134 | return; | 138 | return; |
135 | } | 139 | } |
136 | case 0: // File | 140 | case 0: // File |
137 | { | 141 | { |
138 | QString outputFilename = OGlobalSettings::debugOutput(); | 142 | QString outputFilename = OGlobalSettings::debugOutput(); |
139 | 143 | ||
140 | const int BUFSIZE = 4096; | 144 | const int BUFSIZE = 4096; |
141 | char buf[BUFSIZE] = ""; | 145 | char buf[BUFSIZE] = ""; |
142 | buf[BUFSIZE-1] = '\0'; | 146 | buf[BUFSIZE-1] = '\0'; |
143 | int nSize; | 147 | int nSize; |
144 | 148 | ||
145 | nSize = snprintf( buf, BUFSIZE-1, "%s: %s", (const char*) areaName, data); | 149 | nSize = snprintf( buf, BUFSIZE-1, "%s: %s", (const char*) areaName, data); |
146 | 150 | ||
147 | QFile outputFile( outputFilename ); | 151 | QFile outputFile( outputFilename ); |
148 | if ( outputFile.open( IO_WriteOnly | IO_Append ) ) | 152 | if ( outputFile.open( IO_WriteOnly | IO_Append ) ) |
149 | { | 153 | { |
150 | if ( ( nSize == -1 ) || ( nSize >= BUFSIZE ) ) | 154 | if ( ( nSize == -1 ) || ( nSize >= BUFSIZE ) ) |
151 | { | 155 | { |
152 | outputFile.writeBlock( buf, BUFSIZE-1 ); | 156 | outputFile.writeBlock( buf, BUFSIZE-1 ); |
153 | } | 157 | } |
154 | else | 158 | else |
155 | { | 159 | { |
156 | outputFile.writeBlock( buf, nSize ); | 160 | outputFile.writeBlock( buf, nSize ); |
157 | } | 161 | } |
158 | } | 162 | } |
159 | else | 163 | else |