ConsoleWidget::ConsoleWidget(QWidget * parent) :
	QWidget(parent)
{
	_ui = new Ui_consoleWidget();
	_ui->setupUi(this);
	UEventsManager::addHandler(this);
	_ui->textEdit->document()->setMaximumBlockCount(MAXIMUM_ITEMS);
	_textCursor = new QTextCursor(_ui->textEdit->document());
	_ui->textEdit->setFontPointSize(10);
	QPalette p(_ui->textEdit->palette());
	p.setColor(QPalette::Base, Qt::black);
	_ui->textEdit->setPalette(p);
	_errorMessage = new QMessageBox(QMessageBox::Critical, tr("Fatal error occurred"), "", QMessageBox::Ok, this);
	_errorMessageMutex.lock();
	_time.start();
	_timer.setSingleShot(true);
	connect(_ui->pushButton_clear, SIGNAL(clicked()), _ui->textEdit, SLOT(clear()));
	connect(this, SIGNAL(msgReceived(const QString &, int)), this, SLOT(appendMsg(const QString &, int)));
	connect(&_timer, SIGNAL(timeout()), this, SLOT(flushConsole()));
}
Ejemplo n.º 2
0
void VisualLog::asObject(const QString &type, const MLNode &mlvalue){
    QByteArray str;
    ml::toJson(mlvalue, str);
    QString pref = prefix();
    QString writeData =
        pref + "\\@" + type + "\n" +
        QString(pref.length(), ' ') + str + "\n";

    if ( m_output & VisualLog::Console && m_configuration->m_logObjects & VisualLog::Console ){
        flushConsole(writeData);
        m_output &= ~VisualLog::Console; // remove console flag from text based logging
    }
    if ( m_output & VisualLog::File && m_configuration->m_logObjects & VisualLog::File ){
        flushFile(writeData);
        m_output &= ~VisualLog::File; // remove file flag from text based logging
    }
    if ( m_output & VisualLog::Extensions && m_configuration->m_logObjects & VisualLog::Extensions){
        for ( auto it = m_configuration->m_transports.begin(); it != m_configuration->m_transports.end(); ++it ){
            (*it)->onObject(m_configuration, m_messageInfo, type, mlvalue);
        }
    }
}