]>
git.siccegge.de Git - frida/frida.git/blob - src/gui/widgets/LogDockAppender.cxx
1 #include "LogDockAppender.hxx"
4 #include <log4cxx/patternlayout.h>
6 using namespace log4cxx::helpers
;
8 IMPLEMENT_LOG4CXX_OBJECT(LogDockAppender
)
10 LogDockAppender::LogDockAppender()
12 layout
= new PatternLayout("%d{MMM dd yyyy HH:mm:ss,SSS} - %m %n");
15 void LogDockAppender::append(const spi::LoggingEventPtr
& event
, Pool
& p
) {
16 log4cxx::LogString message
, timestamp
;
18 if ( this->layout
== NULL
) {
19 LOG4CXX_ENCODE_CHAR(nameStr
, name
);
20 std::string
msg("No Layout set for the appender named [ ");
24 LOG4CXX_DECODE_CHAR(msgL
, msg
);
25 errorHandler
->error(msgL
);
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
);
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);
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();
56 void LogDockAppender::setTarget(LogDock
*target
) {
57 this->target
= target
;
60 void LogDockAppender::close() {
64 bool LogDockAppender::requiresLayout() const {