[收藏]把ACE里的日志回调出来

#include <ace/ACE.h>
#include <ace/Log_Msg.h>
#include <ace/Log_Msg_Callback.h>
#include <ace/Log_Record.h>
#include <iostream>
using namespace std;
class LogCall : public ACE_Log_Msg_Callback
{
public:
    LogCall(){}
    ~LogCall(){}
    virtual void log (ACE_Log_Record &log_record)
    {
        cout<<"这是回调之后打印出来的内容:"<<endl;
        cout<<log_record.msg_data()<<endl;
    }
};

int ACE_TMAIN(int, ACE_TCHAR *[])
{
    LogCall *pCall=new LogCall();
    ACE_LOG_MSG->set_flags(ACE_Log_Msg::MSG_CALLBACK);
    //ACE_LOG_MSG->clr_flags(ACE_Log_Msg::STDERR);
    ACE_LOG_MSG->msg_callback(pCall);
    ACE_DEBUG((LM_ERROR,ACE_TEXT(" %D大家好啊\n")));
    getchar();
    return 0;
}

   FILE *stream;
   char list[30];
   int  i, numread, numwritten;

   /* Open file in text mode: */
   if( (stream = fopen( "fread.out", "w+t" )) != NULL )
   {
      for ( i = 0; i < 25; i++ )
         list[i] = (char)('z' - i);
      /* Write 25 characters to stream */
      numwritten = fwrite( list, sizeof( char ), 25, stream );
      printf( "Wrote %d items\n", numwritten );
      fclose( stream );

   }
   else
      printf( "Problem opening the file\n" );

   if( (stream = fopen( "fread.out", "r+t" )) != NULL )
   {
      /* Attempt to read in 25 characters */
      numread = fread( list, sizeof( char ), 25, stream );
      printf( "Number of items read = %d\n", numread );
      printf( "Contents of buffer = %.25s\n", list );
      fclose( stream );
   }
   else
      printf( "File could not be opened\n" );

转载于:https://www.cnblogs.com/tionase/archive/2007/01/12/619214.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值