void ConsoleWidget::logMessage(LogLevel level, QString message) { if (QThread::currentThread() != QCoreApplication::instance()->thread()){ emit logMessageSignal(static_cast<int>(level), message); return; } switch (level) { case LogLevel::Error: { textField_->setTextColor(errorTextColor_); errorsLabel_->setText(toString(++numErrors_).c_str()); break; } case LogLevel::Warn: { textField_->setTextColor(warnTextColor_); warningsLabel_->setText(toString(++numWarnings_).c_str()); break; } case LogLevel::Info: { textField_->setTextColor(infoTextColor_); infoLabel_->setText(toString(++numInfos_).c_str()); break; } } textField_->append(message); QTextCursor c = textField_->textCursor(); c.movePosition(QTextCursor::End); textField_->setTextCursor(c); }
void Monitor::log(const char* fmt, ...) { static char buf[512]; va_list v; va_start(v, fmt); vsnprintf(buf, sizeof(buf), fmt, v); va_end(v); logMessageSignal("[rosmon]", buf); }