关于logcat的使用

关于logcat的使用

根据system/core/include/cutils/log.h中的定义:
 49 /*
 50  * Normally we strip ALOGV (VERBOSE messages) from release builds.
 51  * You can modify this (for example with "#define LOG_NDEBUG 0"
 52  * at the top of your source file) to change that behavior.
 53  */


只有将  #define LOG_NDEBUG 0 放在你的代码中后,ALOGV才会有效。当然,你必须放在
#include <cutils/log.h>  的前面!
这里你同样可以打印文件名,函数名,行号:
 50     ALOGV("yasin test file=%s\n", __FILE__);
 51     ALOGV("yasin test func=%s\n", __func__);
 52     ALOGV("yasin test line=%d\n", __LINE__);
这里用法和内核一样。

你可以在你的源码前面定义一个TAG,比如:
#define LOG_TAG "lights"
这样将来logcat出来的东西就是这样的:
V/lights  (  422): yasin test file=device/sprd/common/libs/liblights/lights.c
V/lights  (  422): yasin test func=write_int
V/lights  (  422): yasin test line=52

这里的lights就是你的TAG ,V代表优先级是最低一级。

你还可以在logcat时加一些参数,比如:根据TAG只打印你自己log,或者只打印某个优先级以上的log等等,如:
logcat   lights:V    *:S

这里的含义就是只打印TAG为lights,且优先级为V以上的都打印。其他标签的只打印S级别的。(S级别是最高级别)这样一来,别的log就都被过滤了,只剩下标签未lights的所有级别的了。也就是只剩你的关于lights的所有级别的log


更多logcat使用方式参考:http://www.oschina.net/question/565065_67884


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

YasinLeeX

再来一杯西湖龙井。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值