当前位置: 首页>>代码示例>>C++>>正文


C++ LogRecord::getLogLevel方法代码示例

本文整理汇总了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();
	}
}
开发者ID:alaindomissy,项目名称:nanoengineer,代码行数:34,代码来源:LogHandlerWidget.cpp

示例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;
}
开发者ID:,项目名称:,代码行数:94,代码来源:


注:本文中的LogRecord::getLogLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。