// Copyright 2008 Nanorex, Inc. See LICENSE file for details. #include "LogHandlerWidget.h" /* CONSTRUCTOR */ LogHandlerWidget::LogHandlerWidget(NXLogLevel logLevel, QWidget* parent) : QWidget(parent), NXLogHandler(logLevel), Ui_LogHandlerWidget() { setupUi(this); QFont font; #if defined(WIN32) font.setPointSize(8); // TODO: set #elif defined(__APPLE__) font.setPointSize(11); #else // Linux font.setPointSize(8); #endif textEdit->setFont(font); } /* FUNCTION: sizeHint */ QSize LogHandlerWidget::sizeHint() const { return QSize(50, 50); } /* FUNCTION: publish */ void LogHandlerWidget::publish(LogRecord logRecord) { if (logRecord.getLogLevel() >= logLevel) { //mutex.lock(); QString color = ""; QString bgcolor = ""; if (logRecord.getLogLevel() == 3) bgcolor = "yellow"; if (logRecord.getLogLevel() == 4) { bgcolor = "orange"; } QString level = QString("%1").arg(LogLevelNames[logRecord.getLogLevel()], 7); level.replace(QString(" "), QString(" ")); QString source = logRecord.getSource().length() == 0 ? "" : logRecord.getSource().append(": ").c_str(); QString message = QString("
%1 | [%4 ] | %5 %6 |