本文整理汇总了C++中LogRecord::getLogLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ LogRecord::getLogLevel方法的具体用法?C++ LogRecord::getLogLevel怎么用?C++ LogRecord::getLogLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogRecord
的用法示例。
在下文中一共展示了LogRecord::getLogLevel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: publish
/* FUNCTION: publish */
void LogHandlerWidget::publish(LogRecord logRecord) {
if (logRecord.getLogLevel() >= logLevel) {
//mutex.lock();
QString color = "";
QString bgcolor = "";
if (logRecord.getLogLevel() == 3)
bgcolor = "yellow";
if (logRecord.getLogLevel() == 4) {
bgcolor = "orange";
}
QString level =
QString("%1").arg(LogLevelNames[logRecord.getLogLevel()], 7);
level.replace(QString(" "), QString(" "));
QString source =
logRecord.getSource().length() == 0 ?
"" : logRecord.getSource().append(": ").c_str();
QString message =
QString("<table border=0 cellspacing=0 cellpadding=0><tr><td><font color=grey>%1 </font></td><td bgcolor=%2><font type=courier color=%3>[<code>%4</code>] </font></td><td bgcolor=%2><font color=%3>%5 %6</font></td></tr></table>")
.arg(logRecord.getDateTime()
.toString("yyyy-MM-dd hh:mm:ss.zzz"))
.arg(bgcolor).arg(color)
.arg(level)
.arg(source)
.arg(logRecord.getMessage().c_str());
textEdit->insertHtml(message);
textEdit->ensureCursorVisible();
if (logRecord.getLogLevel() > 2)
emit raiseWidget();
//mutex.unlock();
}
}
示例2: addLogDetails
am_status_t LogService::addLogDetails(const std::string& logName,
const LogRecord& record,
const std::string& loggedByTokenID)
{
ScopeLock scopeLock(mLock);
char logLevel[32];
am_status_t status = AM_SUCCESS;
char *msg = NULL;
std::string message = record.getLogMessage();
//The encoded log message needs to be in multiple of 4 bytes.
msg = (char *)malloc(((message.size() * 4/3 + 1)/4+1)*4 + 4);
if(msg != NULL) {
encode_base64(message.c_str(), message.size(), msg);
} else {
status = AM_NO_MEMORY;
}
if (status == AM_SUCCESS) {
if(!remoteBodyChunkListInitialized) {
const std::size_t NUM_EXTRA_CHUNKS = 50;
remoteRequest = new Request(*this, requestPrefixChunk,
logRequestPrefixChunk, NUM_EXTRA_CHUNKS);
if (remoteRequest != NULL) {
remoteBodyChunkList = remoteRequest->getBodyChunkList();
remoteBodyChunkListInitialized = true;
}
}
if(bufferCount >= 1) {
remoteBodyChunkList.push_back(additionalRequestPrefixChunk);
BodyChunk temp;
char serviceIdBuf[1024];
if (remoteRequest != NULL) {
remoteRequest->getNextServiceRequestIdAsString(
serviceIdBuf, sizeof(serviceIdBuf));
}
temp.data = serviceIdBuf;
remoteBodyChunkList.push_back(temp);
}
sprintf(logLevel, "%d", record.getLogLevel());
remoteBodyChunkList.push_back(logLogPrefixChunk);
remoteBodyChunkList.push_back(BodyChunk(logName));
remoteBodyChunkList.push_back(logSidPrefixChunk);
remoteBodyChunkList.push_back(BodyChunk(loggedByTokenID));
remoteBodyChunkList.push_back(logLogSuffixChunk);
remoteBodyChunkList.push_back(logRecordPrefixChunk);
remoteBodyChunkList.push_back(logLevelPrefixChunk);
remoteBodyChunkList.push_back(BodyChunk(std::string(logLevel)));
remoteBodyChunkList.push_back(logLevelSuffixChunk);
remoteBodyChunkList.push_back(logRecMsgPrefixChunk);
std::string t_mesg(msg);
free(msg);
Utils::expandEntityRefs(t_mesg);
remoteBodyChunkList.push_back(BodyChunk(t_mesg));
remoteBodyChunkList.push_back(logRecMsgSuffixChunk);
remoteBodyChunkList.push_back(logInfoMapPrefixChunk);
const Properties &properties = record.getLogInfo();
Properties::const_iterator iter = properties.begin();
for(; iter != properties.end(); iter++) {
const Properties::key_type &k_iter = iter->first;
const Properties::mapped_type &v_iter = iter->second;
std::string keyStr("");
keyStr = k_iter.c_str();
std::string valueStr("");
valueStr = v_iter.c_str();
remoteBodyChunkList.push_back(logInfoKeyPrefixChunk);
remoteBodyChunkList.push_back(BodyChunk(keyStr));
remoteBodyChunkList.push_back(logInfoKeySuffixChunk);
remoteBodyChunkList.push_back(logInfoValuePrefixChunk);
remoteBodyChunkList.push_back(BodyChunk(valueStr));
remoteBodyChunkList.push_back(logInfoValueSuffixChunk);
}
remoteBodyChunkList.push_back(logInfoMapSuffixChunk);
remoteBodyChunkList.push_back(logRecordSuffixChunk);
remoteBodyChunkList.push_back(requestSuffixChunk);
bufferCount++;
} else {
status = AM_NO_MEMORY;
}
return status;
}