您的位置:首页 > 移动开发

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

2006-09-17 00:44 337 查看
 

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就可以了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐