Example #1
0
LogWindow::LogWindow(QWidget *theParent) :
    QMainWindow(theParent),
    ui(new Ui::LogWindow),
    m_log(NULL),
    m_maxEntries(NULL),
    m_logEntryBlockFormat(new QTextBlockFormat()),
    m_timeStampFormat(new QTextCharFormat()),
    m_debugMessageFormat(new QTextCharFormat()),
    m_notificationFormat(new QTextCharFormat()),
    m_warningFormat(new QTextCharFormat()),
    m_errorFormat(new QTextCharFormat()),
    m_moleQueueIdFormat(new QTextCharFormat()),
    m_messageFormat(new QTextCharFormat())
{
    createUi();

    // Restore geometry
    QSettings settings;
    settings.beginGroup("logWindow");
    restoreGeometry(settings.value("geometry").toByteArray());
    restoreState(settings.value("windowState").toByteArray());
    settings.endGroup();

    setupFormats();

    connect(Logger::getInstance(), SIGNAL(newLogEntry(MoleQueue::LogEntry)),
            this, SLOT(addLogEntry(MoleQueue::LogEntry)));

    initializeLogText();
}
Example #2
0
void createEntry(QString source,QString text, bool error) {
    QSqlQuery qry;
    int newId = -1;

    // If the query is successful return id
    if (qry.exec(QString("INSERT INTO log VALUES (NULL,'%1','%2','%3')").arg(source).arg(entry).arg(error))) {
        newId = qry.lastInsertId().toInt();
        emit newLogEntry(newId);
    } else {
        qDebug() << "Unable to create log entry";
    }
}
Example #3
0
void DefaultLog::add(Level l, QString message)
{
	QMutexLocker locker(&logAccess);

	QTextStream out(stdout);
	QTextStream err(stderr);

	if (l == LOGERROR) err<<	"ERROR   " << pluginId << ": " << message << endl;
	if (l == LOGDEBUG) out<<	"DEBUG   " << pluginId << ": " << message << endl;
	if (l == LOGINFO) out<<		"INFO    " << pluginId << ": " << message << endl;
	if (l == LOGWARNING) out<<	"WARNING " << pluginId << ": " << message << endl;

	loggedEvents.append(LogEntry());
	loggedEvents.last().level = l;
	loggedEvents.last().message = message;
	loggedEvents.last().pluginId = pluginId;

	emit newLogEntry();
}
Example #4
0
void Logger::handleNewLogEntry(LogEntry &entry)
{
  entry.setTimeStamp();
  m_log.push_back(entry);

  trimLog();

  switch (entry.entryType()) {
  case LogEntry::DebugMessage:
    handleNewDebugMessage(entry);
    break;
  case LogEntry::Notification:
    handleNewNotification(entry);
    break;
  case LogEntry::Warning:
    handleNewWarning(entry);
    break;
  case LogEntry::Error:
    handleNewError(entry);
    break;
  }
  emit newLogEntry(entry);
}
Example #5
0
/**
 * Parses CID and CIDLOG lines with the following format:
 * CID: *DATE*18052012*TIME*1743*LINE*0123456789*NMBR*0987654321*MESG*NONE*NAME*NO NAME*
 * CIDLOG: *DATE*11052012*TIME*1331*LINE*0123456789*NMBR*Anonym*MESG*NONE*NAME*NO NAME*
 *
 * @param line The line to parse
 */
void QNcidSocket::parseCID(QString line)
{
    LogEntry entry;
    QDate date = QDate(0,0,0);
    QTime time = QTime(0,0);
    QStringList f = line.split("*");
    for (int i=1; i<f.length()-1; i+=2) {
        if (f[i].compare("DATE",Qt::CaseInsensitive) == 0) {
            date.setDate(f[i+1].right(4).toInt(),f[i+1].mid(2,2).toInt(),f[i+1].left(2).toInt());
        }
        else if (f[i].compare("TIME",Qt::CaseInsensitive) == 0) {
            time = QTime::fromString(f[i+1],"hhmm");
        }
        else if (f[i].compare("LINE",Qt::CaseInsensitive) == 0) {
            entry.phoneLine = f[i+1];
        }
        else if (f[i].compare("NMBR",Qt::CaseInsensitive) == 0) {
            entry.callerId = f[i+1];
        }
        else if (f[i].compare("NAME",Qt::CaseInsensitive) == 0) {
            entry.name = f[i+1];
        }
        else if (f[i].compare("MESG",Qt::CaseInsensitive) == 0) {
            entry.msg = f[i+1];
        }
        else {
            qDebug() << "parseCID(): Unkown part:" << f[i+1];
        }
    }
    entry.date = QDateTime(date, time);
    emit newLogEntry(entry);

    qDebug() << "parseCID(): Number:" << entry.callerId << "Time:" << entry.date.toString();

    if (line.startsWith("CID:",Qt::CaseInsensitive)) emit incommingCall(entry);
}
Example #6
0
void LogEmitter::addLogEntry(const QString &msg) {
	emit newLogEntry(msg);
};
Example #7
0
LogTester::LogTester() :
	correctLogEntries(0), log(Log::getLogger("logger"))
{
	QObject::connect(log, SIGNAL(newLogEntry()), this, SLOT(newLogEntryAdded()), Qt::QueuedConnection);
}