• 大小: 3KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-01-07
  • 语言: 其他
  • 标签: 开源log  

资源简介

将log4cxx封装成LOG(level,format,content)的形式,方便使用,也可用于其他开源日志框架的封装,包含log4cxx的详细配置文件。

资源截图

代码片段和文件信息

#include “log.h“
static std::string ensure_log_complete(IN const char* formatIN va_list args)
{
if (NULL == format)
{
return ““;
}

int iNum = 0;
unsigned int uiSize = 1024;
string strLog(““);

char *pcBuff = new(std::nothrow) char[uiSize];
if (NULL == pcBuff)
{
return strLog;
}

while(true)
{
bzero(pcBuff uiSize);

iNum = vsnprintf(pcBuff uiSize format args);
if ((iNum > -1) && (iNum < (int)uiSize))
{
strLog = pcBuff;
SAFE_DELETE_ARRAY(pcBuff);

return strLog;
}

//如果字符串值比默认分配大,则分配更大空间
uiSize = (iNum > -1)?(int)(iNum + 1):(uiSize * 2);
SAFE_DELETE_ARRAY(pcBuff);

pcBuff = new(std::nothrow) char[uiSize];
if (NULL == pcBuff)
{
return strLog;
}
}

SAFE_DELETE_ARRAY(pcBuff);

return strLog

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        2223  2016-09-09 10:27  log4cxx\log.cpp
     文件         899  2016-09-09 10:26  log4cxx\log.h
     文件        3967  2016-06-29 04:15  log4cxx\log4cxx.cfg
     目录           0  2016-09-09 10:33  log4cxx\

评论

共有 条评论

相关资源