In Android 4.0.3,
I modified the file "system/core/include/cutils/log.h"
I added the code below:/*
* my log for trace code
*/
#ifndef MYNO
#define MYNO
static long myNo = 0;
#endif
//
#ifndef MYLOG
#define MYLOG(...) \
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "***It's My Log!*** No. %ld: ", myNo); \
__android_log_print(ANDROID_LOG_ERROR, NULL, __VA_ARGS__); \
myNo++;
#endifWhen i use logcat -s InputReader to see my log, i can only see:
E/InputReader( 308): ***It's My Log!*** No. 0:
E/InputReader( 308): ***It's My Log!*** No. 1: Must I change the second __android_log_print: NULL to LOG_CAT?
But I want to see the input events show after the number.I really track the MACRO to know why, but I just can's get the reason.
How can I solve this problem?
I modified the file "system/core/include/cutils/log.h"
I added the code below:/*
* my log for trace code
*/
#ifndef MYNO
#define MYNO
static long myNo = 0;
#endif
//
#ifndef MYLOG
#define MYLOG(...) \
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "***It's My Log!*** No. %ld: ", myNo); \
__android_log_print(ANDROID_LOG_ERROR, NULL, __VA_ARGS__); \
myNo++;
#endifWhen i use logcat -s InputReader to see my log, i can only see:
E/InputReader( 308): ***It's My Log!*** No. 0:
E/InputReader( 308): ***It's My Log!*** No. 1: Must I change the second __android_log_print: NULL to LOG_CAT?
But I want to see the input events show after the number.I really track the MACRO to know why, but I just can's get the reason.
How can I solve this problem?
解决方案 »
- 用android模拟器调试GPS定位程序出现的问题
- android源码中添加图片
- 横竖屏下camera的previewSize问题
- 播放音乐后再调节音量加减按钮实际音量有变化,但取得的音量值没变化
- 搭建android环境的时候总是出错,谁能帮我啊
- android 如何监听程序从前台转入后台,谢谢
- 各位高手,帮忙看看,使用Hierarchy viewer的时候总是报错!
- Android togglebutton 实现问题
- Gsensor校准apk 如何判断gsensor的报点是否准确以及xyz轴的判定,跪求解决
- 如何实现一个按钮中的图片再几秒钟之后被替换成其他图片
- SurfaceView屏幕闪烁与双缓冲
- Git如何查看某次提交某个文件的修改
"..." + __VA_ARGS__
两个字符串不能相加的。
我找到解决办法了,就是仿照__android_log_print重新定义一个MYPRINT:static int MYPRINT(int prio, const char *tag, const char *fmt, ...) {
va_list ap; char *my_tag = "***It's My Log!*** No. ";
int len; char buf[LOG_BUF_SIZE];
len = sprintf(buf, "%s%ld: ", my_tag, myNo++); va_start(ap, fmt);
vsnprintf(buf+len, LOG_BUF_SIZE-len, fmt, ap);
va_end(ap); return __android_log_write(prio, tag, buf);
}