]> git.siccegge.de Git - frida/frida.git/commitdiff
Color logmessages according to severity
authorChristoph Egger <siccegge@stud.informatik.uni-erlangen.de>
Tue, 19 May 2015 17:55:35 +0000 (19:55 +0200)
committerChristoph Egger <christoph@anonymous.siccegge.de>
Tue, 19 May 2015 17:56:17 +0000 (19:56 +0200)
Closes T12

src/gui/widgets/LogDockAppender.cxx

index f6419c27601b346d7651fe67fd74caaa2cf0b5bf..5003139d1f3c269b4fc5426f6f8838252ac7ab96 100644 (file)
@@ -15,28 +15,42 @@ LogDockAppender::LogDockAppender()
 void LogDockAppender::append(const spi::LoggingEventPtr& event, Pool& p) {
        log4cxx::LogString message, timestamp;
 
-       if ( this->layout == NULL ) {
-             LOG4CXX_ENCODE_CHAR(nameStr, name);
-             std::string msg("No Layout set for the appender named [ ");
-             msg.append(nameStr);
-             msg.append(" ].");
-
-             LOG4CXX_DECODE_CHAR(msgL, msg);
-             errorHandler->error(msgL);
-           return;
-       }
-
-       layout->format(message, event, p);
-       timeformat.format(timestamp, event->getTimeStamp(), p);
-       LOG4CXX_ENCODE_CHAR(messageencode, message);
-       LOG4CXX_ENCODE_CHAR(timestampencode, timestamp);
-
-       int rowcount = target->rowCount();
-       target->insertRow(rowcount);
-       target->setItem(rowcount, 0, new QTableWidgetItem(timestampencode.c_str()));
-       target->setItem(rowcount, 1, new QTableWidgetItem(event->getLevel()->toString().c_str()));
-       target->setItem(rowcount, 2, new QTableWidgetItem(messageencode.c_str()));
-       target->resizeColumnsToContents();
+       if ( this->layout == NULL ) {
+               LOG4CXX_ENCODE_CHAR(nameStr, name);
+               std::string msg("No Layout set for the appender named [ ");
+               msg.append(nameStr);
+               msg.append(" ].");
+
+               LOG4CXX_DECODE_CHAR(msgL, msg);
+               errorHandler->error(msgL);
+               return;
+       }
+
+       layout->format(message, event, p);
+       timeformat.format(timestamp, event->getTimeStamp(), p);
+       LOG4CXX_ENCODE_CHAR(messageencode, message);
+       LOG4CXX_ENCODE_CHAR(timestampencode, timestamp);
+
+       QColor rowcolor(0xff, 0xff, 0xff, 0xff);
+       if (log4cxx::Level::getFatal() == event->getLevel()) {
+               rowcolor.setRgb(0xff, 0x00, 0x22);
+       } else if (log4cxx::Level::getError() == event->getLevel()) {
+               rowcolor.setRgb(0xff, 0x00, 0x00);
+       } else if (log4cxx::Level::getWarn() == event->getLevel()) {
+               rowcolor.setRgb(0x00, 0xff, 0xff);
+       } else if (log4cxx::Level::getTrace() == event->getLevel()) {
+               rowcolor.setRgb(0xee, 0xff, 0xee);
+       }
+
+       int rowcount = target->rowCount();
+       target->insertRow(rowcount);
+       target->setItem(rowcount, 0, new QTableWidgetItem(timestampencode.c_str()));
+       target->setItem(rowcount, 1, new QTableWidgetItem(event->getLevel()->toString().c_str()));
+       target->setItem(rowcount, 2, new QTableWidgetItem(messageencode.c_str()));
+       target->item(rowcount, 0)->setBackground(rowcolor);
+       target->item(rowcount, 1)->setBackground(rowcolor);
+       target->item(rowcount, 2)->setBackground(rowcolor);
+       target->resizeColumnsToContents();
 }
 
 void LogDockAppender::setTarget(LogDock *target) {