ACE_TRACE为何不产生日志方法调用?

 

hi all
i had installed ACE5.5 OS windows 2000 c++ build 6.0
lib: ACE_bd.lib

I am reading "
ACE Programmer's Guide, The: Practical Design Patterns for Network and
Systems Programming"


the code
Let's take a look at a simple application:


#include "ace/Log_Msg.h"

void foo (void);

int ACE_TMAIN (int, ACE_TCHAR *[])
{
ACE_TRACE(ACE_TEXT ("main"));

ACE_DEBUG ((LM_INFO, ACE_TEXT ("%IHi Mom/n")));
foo();
ACE_DEBUG ((LM_INFO, ACE_TEXT ("%IGoodnight/n")));

return 0;
}

void foo (void)
{
ACE_TRACE (ACE_TEXT ("foo"));

ACE_DEBUG ((LM_INFO, ACE_TEXT ("%IHowdy Pardner/n")));
}


If you compile and execute the preceding code, you should get something
like this:



(1024) calling main in file `Simple1.cpp' on line 7
Hi Mom
(1024) calling foo in file `Simple1.cpp' on line 18
Howdy Pardner
(1024) leaving foo
Goodnight
(1024) leaving main

:( but what i get is
Hi Mom
Howdy Pardner
Goodnight

The compile-time values of three configuration settings control whether
the logging macros produce logging method calls: ACE_NTRACE,
ACE_NDEBUG, and ACE_NLOGGING.
so i change it
my code is

#include "ace/Log_Msg.h"

#define ACE_NTRACE 0
#define ACE_NDEBUG 0
#define ACE_NLOGGING 0


void foo (void);

int ACE_TMAIN (int, ACE_TCHAR *[])
{
ACE_TRACE(ACE_TEXT ("main"));

ACE_DEBUG ((LM_INFO, ACE_TEXT ("%IHi Mom/n")));
foo();
ACE_DEBUG ((LM_INFO, ACE_TEXT ("%IGoodnight/n")));

system("Pause");
return 0;
}

void foo (void)
{
ACE_TRACE (ACE_TEXT ("foo"));

ACE_DEBUG ((LM_INFO, ACE_TEXT ("%IHowdy Pardner/n")));
}


i still get
Hi Mom
Howdy Pardner
Goodnight

what 's wrong with my code? thank you

benjiam

Hi,


i had installed ACE5.5 OS windows 2000 c++ build 6.0
lib: ACE_bd.lib

I am reading "
ACE Programmer's Guide, The: Practical Design Patterns for Network and
Systems Programming"


the code
Let's take a look at a simple application:


#include "ace/Log_Msg.h"

void foo (void);

int ACE_TMAIN (int, ACE_TCHAR *[])
{
ACE_TRACE(ACE_TEXT ("main"));

ACE_DEBUG ((LM_INFO, ACE_TEXT ("%IHi Mom/n")));
foo();
ACE_DEBUG ((LM_INFO, ACE_TEXT ("%IGoodnight/n")));

return 0;
}

void foo (void)
{
ACE_TRACE (ACE_TEXT ("foo"));

ACE_DEBUG ((LM_INFO, ACE_TEXT ("%IHowdy Pardner/n")));
}


If you compile and execute the preceding code, you should get something
like this:


(1024) calling main in file `Simple1.cpp' on line 7
Hi Mom
(1024) calling foo in file `Simple1.cpp' on line 18
Howdy Pardner
(1024) leaving foo
Goodnight
(1024) leaving main

:( but what i get is
Hi Mom
Howdy Pardner
Goodnight

The compile-time values of three configuration settings control whether
the logging macros produce logging method calls: ACE_NTRACE,
ACE_NDEBUG, and ACE_NLOGGING.
so i change it
my code is

#include "ace/Log_Msg.h"

#define ACE_NTRACE 0
#define ACE_NDEBUG 0
#define ACE_NLOGGING 0


I think you need to set this stuff *before* you #include any ACE
files... Please see

ACE_ROOT/examples/Misc/test_trace.cpp

for an example of how to do it right.

thanks,

Doug



void foo (void);

int ACE_TMAIN (int, ACE_TCHAR *[])
{
ACE_TRACE(ACE_TEXT ("main"));

ACE_DEBUG ((LM_INFO, ACE_TEXT ("%IHi Mom/n")));
foo();
ACE_DEBUG ((LM_INFO, ACE_TEXT ("%IGoodnight/n")));

system("Pause");
return 0;
}

void foo (void)
{
ACE_TRACE (ACE_TEXT ("foo"));

ACE_DEBUG ((LM_INFO, ACE_TEXT ("%IHowdy Pardner/n")));
}


i still get
Hi Mom
Howdy Pardner
Goodnight

what 's wrong with my code? thank you

benjiam

------------------------------------------------------------------------------------------------------------------------------

照着Doug回复的方法,在#include 之前加了一条#define ACE_NTRACE 0 ,问题解决了 。在《指南》中也这样说到,ACE_TRACE的值默认为1(禁用),它被解释为“不”。因此,要使ACE_TRACE产生日志方法调用,把它设为0就可以了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值