本文整理汇总了C++中LogEntry::timestamp方法的典型用法代码示例。如果您正苦于以下问题:C++ LogEntry::timestamp方法的具体用法?C++ LogEntry::timestamp怎么用?C++ LogEntry::timestamp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogEntry
的用法示例。
在下文中一共展示了LogEntry::timestamp方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print
void StdLogOutput::print(const LogEntry &entry)
{
//const QString timestamp(entry.timestamp().toString("yy-MM-dd::hh:mm:ss"));
const QString timestamp(entry.timestamp().toString("hh:mm:ss"));
switch(entry.type())
{
case LogEntry::DEBUG_LOG:
std::cout << QString("%1 %2 %3: %4").arg(timestamp).arg(entry.file()).arg(entry.line()).arg(entry.message()).toStdString() << std::endl;
break;
case LogEntry::ERROR_LOG:
std::cout << QString("%1 error: %2").arg(timestamp).arg(entry.message()).toStdString() << std::endl;
break;
case LogEntry::INFORMATION_LOG:
case LogEntry::MESSAGE_LOG:
case LogEntry::WORKFLOW_LOG:
std::cout << QString("%1: %2").arg(timestamp).arg(entry.message()).toStdString() << std::endl;
break;
case LogEntry::WARNING_LOG:
std::cout << QString("%1 warning: %2").arg(timestamp).arg(entry.message()).toStdString() << std::endl;
break;
case LogEntry::EMPTYLINE_LOG:
std::cout << std::endl << std::endl;
break;
case LogEntry::UNDEFINED_LOG:
default:
break;
}
}
示例2: appendLogEntry
void LogEngine::appendLogEntry(const LogEntry &entry)
{
QString queryString = QString("INSERT INTO entries (timestamp, loggingEventType, loggingLevel, sourceType, typeId, deviceId, value, active, errorCode) values ('%1', '%2', '%3', '%4', '%5', '%6', '%7', '%8', '%9');")
.arg(entry.timestamp().toMSecsSinceEpoch())
.arg(entry.eventType())
.arg(entry.level())
.arg(entry.source())
.arg(entry.typeId().toString())
.arg(entry.deviceId().toString())
.arg(entry.value())
.arg(entry.active())
.arg(entry.errorCode());
QSqlQuery query;
query.exec(queryString);
if (query.lastError().isValid()) {
qCWarning(dcLogEngine) << "Error writing log entry. Driver error:" << query.lastError().driverText() << "Database error:" << query.lastError().databaseText();
}
}
示例3: appendLogEntry
void LogEngine::appendLogEntry(const LogEntry &entry)
{
checkDBSize();
QString queryString = QString("INSERT INTO entries (timestamp, loggingEventType, loggingLevel, sourceType, typeId, deviceId, value, active, errorCode) values ('%1', '%2', '%3', '%4', '%5', '%6', '%7', '%8', '%9');")
.arg(entry.timestamp().toTime_t())
.arg(entry.eventType())
.arg(entry.level())
.arg(entry.source())
.arg(entry.typeId().toString())
.arg(entry.deviceId().toString())
.arg(entry.value())
.arg(entry.active())
.arg(entry.errorCode());
QSqlQuery query;
if (!query.exec(queryString)) {
qCWarning(dcLogEngine) << "Error writing log entry. Driver error:" << query.lastError().driverText() << "Database error:" << query.lastError().databaseText();
qCWarning(dcLogEngine) << entry;
return;
}
emit logEntryAdded(entry);
}
示例4: print
void LogOutputWidget::print(const LogEntry &entry)
{
#ifdef _NDEBUG
const QString timestamp(entry.timestamp().toString("hh:mm:ss"));
#else
const QString timestamp(entry.timestamp().toString("hh:mm:ss:zzz"));
#endif
//const QString timestamp(entry.timestamp().toString("hh:mm:ss"));
m_swap->clear();
m_swap->setFont(font());
QString message = entry.message();
switch(entry.type())
{
case LogEntry::INFORMATION_LOG:
m_swap->textCursor().insertText(QString("%1: %2\n").arg(timestamp).arg(message), m_informationCharFormat);
break;
case LogEntry::WARNING_LOG:
m_swap->textCursor().insertText(QString("%1: %2\n").arg(timestamp).arg(message), m_warningCharFormat);
break;
case LogEntry::ERROR_LOG:
m_swap->textCursor().insertText(QString("%1: %2\n").arg(timestamp).arg(message), m_errorCharFormat);
break;
case LogEntry::DEBUG_LOG:
m_swap->textCursor().insertText(QString("%1 %2 %3: %4\n").arg(timestamp).arg(entry.file()).arg(entry.line()).arg(message), m_debugCharFormat);
break;
case LogEntry::MESSAGE_LOG:
m_swap->textCursor().insertText(QString("%1: %2\n").arg(timestamp).arg(message), m_messageCharFormat);
break;
case LogEntry::EMPTYLINE_LOG:
m_swap->textCursor().insertText("\n");
break;
case LogEntry::WORKFLOW_LOG:
case LogEntry::UNDEFINED_LOG:
default:
break;
};
QString htmlMessage = m_swap->toHtml();
QRegExp reEmail("\\b([A-Za-z0-9._%+-][email protected][A-Za-z0-9.-]+\\.[A-Za-z]{2,4})\\b");
QRegExp reLink("\\b((ftp|http|https):\\/\\/(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(\\/|\\/([\\w#!:.?+=&%@!\\-\\/]))?)\\b");
int pos = 0;
while((pos = reEmail.indexIn(message, pos)) != -1)
{
pos += reEmail.matchedLength();
const QString email = reEmail.capturedTexts()[0];
htmlMessage.replace(email, QString("<a href =\"mailto:%1\">%1</a>").arg(email));
}
pos = 0;
while((pos = reLink.indexIn(message, pos)) != -1)
{
pos += reLink.matchedLength();
const QString link = reLink.capturedTexts()[0];
htmlMessage.replace(link, QString("<a href =\"%1\">%1</a>").arg(link));
}
m_cursor->insertHtml(htmlMessage);
ensureCursorVisible();
update();
}