ACE_DEBUG buffer

ACE中输出日志时,发现太长会被截断。

 

1.测试


char buf[5000] = {0};
ACE_OS::memset(buf,'a', 4999);

ACE_DEBUG((LM_INFO,
        ACE_TEXT("##@@##[ %s ]##@@##\n"), 
        buf));

结果显示:

 超过4096个字节被截断

2.在ACE_Log_Msg中使用了 宏ACE_MAXLOGMSGLEN,其定义如下。

// Max size of an ACE Log Record data buffer.  This can be reset in
// the config.h file if you'd like to increase or decrease the size.
# if !defined (ACE_MAXLOGMSGLEN)
#   define ACE_MAXLOGMSGLEN 4 * 1024
# endif /* ACE_MAXLOGMSGLEN */

3. config.h中修改buffer size

4.分段打印

void EpgWebTask::PrintBigMsg(const ACE_UINT8 *payload, ACE_UINT32 payload_len)
{
    const int max_len = 1024 * 2;
    char buf[max_len + 1] = {0};

int part = 0; while(payload_len > max_len * part) { ACE_OS::memset(buf, 0, sizeof(buf)); ACE_OS::snprintf(buf, sizeof(buf),"%s", payload + max_len * part); ACE_DEBUG((LM_INFO, ACE_TEXT("EpgWebTask::PrintBigMsg (part %d) ${ %s }$\n"), part, buf)); part++; } }

 

posted on 2014-04-18 10:02  偏爱省略号  阅读(429)  评论(0编辑  收藏  举报

导航