]> git.siccegge.de Git - frida/frida.git/blob - src/gui/widgets/LogDockAppender.cxx
Make signals from geiser work
[frida/frida.git] / src / gui / widgets / LogDockAppender.cxx
1 #include "LogDockAppender.hxx"
2 #include "LogDock.hxx"
3
4 #include <log4cxx/patternlayout.h>
5
6 using namespace log4cxx::helpers;
7
8 IMPLEMENT_LOG4CXX_OBJECT(LogDockAppender)
9
10 LogDockAppender::LogDockAppender()
11 : timeformat("%T") {
12 layout = new PatternLayout("%d{MMM dd yyyy HH:mm:ss,SSS} - %m %n");
13 }
14
15 void LogDockAppender::append(const spi::LoggingEventPtr& event, Pool& p) {
16 log4cxx::LogString message, timestamp;
17
18 if ( this->layout == NULL ) {
19 LOG4CXX_ENCODE_CHAR(nameStr, name);
20 std::string msg("No Layout set for the appender named [ ");
21 msg.append(nameStr);
22 msg.append(" ].");
23
24 LOG4CXX_DECODE_CHAR(msgL, msg);
25 errorHandler->error(msgL);
26 return;
27 }
28
29 layout->format(message, event, p);
30 timeformat.format(timestamp, event->getTimeStamp(), p);
31 LOG4CXX_ENCODE_CHAR(messageencode, message);
32 LOG4CXX_ENCODE_CHAR(timestampencode, timestamp);
33
34 QColor rowcolor(0xff, 0xff, 0xff, 0xff);
35 if (log4cxx::Level::getFatal() == event->getLevel()) {
36 rowcolor.setRgb(0xff, 0x00, 0x22);
37 } else if (log4cxx::Level::getError() == event->getLevel()) {
38 rowcolor.setRgb(0xff, 0x00, 0x00);
39 } else if (log4cxx::Level::getWarn() == event->getLevel()) {
40 rowcolor.setRgb(0x00, 0xff, 0xff);
41 } else if (log4cxx::Level::getTrace() == event->getLevel()) {
42 rowcolor.setRgb(0xee, 0xff, 0xee);
43 }
44
45 int rowcount = target->rowCount();
46 target->insertRow(rowcount);
47 target->setItem(rowcount, 0, new QTableWidgetItem(timestampencode.c_str()));
48 target->setItem(rowcount, 1, new QTableWidgetItem(event->getLevel()->toString().c_str()));
49 target->setItem(rowcount, 2, new QTableWidgetItem(messageencode.c_str()));
50 target->item(rowcount, 0)->setBackground(rowcolor);
51 target->item(rowcount, 1)->setBackground(rowcolor);
52 target->item(rowcount, 2)->setBackground(rowcolor);
53 target->resizeColumnsToContents();
54 }
55
56 void LogDockAppender::setTarget(LogDock *target) {
57 this->target = target;
58 }
59
60 void LogDockAppender::close() {
61
62 }
63
64 bool LogDockAppender::requiresLayout() const {
65 return true;
66 }