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就可以了。
相关文章推荐
- void prinT(Test *pT)//这个函数 这里为什么要用 我完全可以用t3.print()这样来调用类里面函数方法就可以,为何多此一举来这样一步???
- Java使用注解和动态代理实现方法调用时的日志记录示例
- 基于java.util.logging实现轻量级日志记录库(增加根据当前类class初始化,修复线程池模型(javaEE)下的堆栈轨迹顺序与当前调用方法不一致问题)
- 模拟log4j获取日志对象调用所在的类名、方法名及行号
- 关于java方法调用时产生的StackFrame内部内容。
- Spring AOP进行日志记录,管理 (使用Spring的拦截器功能获取对action中每个方法的调用情况,在方法调用前和调用后记录相关日志。)
- 2017年3月16工作日志【mysql更改字段参数、java8 map()调用方法示例】
- .Net下几种日志管理方法(C# 将Diagnostics.Trace 调试输出 保存到txt)
- Java产生任意范围内的随机字符,内部多种方法进行调用
- 如何防止覆盖(override)toString方法时产生递归调用
- 网页中显示hyper-v,调用IMsRdpClient8时打印OnDisconnected方法的错误日志的代码
- 如何防止覆盖(override)toString方法时产生递归调用
- TP中用D方法创建了模型后,为何调用不了creat,add等方法??!
- 启动ACE_TRACE日志
- hadoop;RPC;调用接口;cmd的jps查看java进程;有main方法的类才能产生进程
- 为何在doGet()方法里调用doPost()方法
- hibernate定时删除日志信息调用的方法
- Spring AOP进行日志记录,管理 (使用Spring的拦截器功能获取对action中每个方法的调用情况,在方法调用前
- 数据库报ORA-00600: 内部错误代码, 参数: [17059],并产生大量trace日志文件
- 使用RMAN从相关的备份集、RMAN备份产生的日志等获取DBID的二种方法