本文整理汇总了C++中LogEntry::entryType方法的典型用法代码示例。如果您正苦于以下问题:C++ LogEntry::entryType方法的具体用法?C++ LogEntry::entryType怎么用?C++ LogEntry::entryType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogEntry
的用法示例。
在下文中一共展示了LogEntry::entryType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addLogEntry
void LogWindow::addLogEntry(const LogEntry &entry)
{
QString entryType;
QTextCharFormat *entryFormat;
switch (entry.entryType()) {
case LogEntry::DebugMessage:
entryType = tr("Debug");
entryFormat = m_debugMessageFormat;
break;
case LogEntry::Notification:
entryType = tr("Notification");
entryFormat = m_notificationFormat;
break;
case LogEntry::Warning:
entryType = tr("Warning");
entryFormat = m_warningFormat;
break;
case LogEntry::Error:
entryType = tr("Error");
entryFormat = m_errorFormat;
break;
default:
entryType = tr("LogEntry");
entryFormat = m_debugMessageFormat;
}
QTextDocument *doc = m_log->document();
QTextCursor cur(doc);
cur.beginEditBlock();
cur.movePosition(QTextCursor::Start);
cur.insertBlock(*m_logEntryBlockFormat);
cur.insertText(entry.timeStamp().toString("[yyyy-MM-dd hh:mm:ss]"),
*m_timeStampFormat);
cur.insertText(" ");
cur.insertText(QString("%1").arg(entryType, -12), *entryFormat);
cur.insertText(" ");
if (entry.moleQueueId() == InvalidId) {
cur.insertText(tr("Job %1").arg("N/A", -6), *m_moleQueueIdFormat);
}
else {
cur.insertText(tr("Job %1").arg(entry.moleQueueId(), -6),
*m_moleQueueIdFormat);
}
cur.insertText(" ");
// Modify newlines to align with the hanging indent.
cur.insertText(entry.message().replace(QRegExp("\\n+"), "\n "),
*m_messageFormat);
cur.endEditBlock();
}
示例2: handleNewLogEntry
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);
}