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

来源:互联网 发布:台式机品牌 知乎 编辑:程序博客网 时间:2024/04/29 02:35
 
  • can not get debug infor form ACE_TRACE

  • Author: papamms |
  • Date: 15-05-2006 |
  • Posted in: comp.soft-sys.ace |
  • Show original

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
  • Reply by: Douglas C. Schmidt |
  • Date: 15-05-2006 |
  • Show original

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就可以了。

原创粉丝点击