Android NDK __android_log_print函数和LogCat [英] Android NDK __android_log_print function and LogCat

查看:188
本文介绍了Android NDK __android_log_print函数和LogCat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有类似

__android_log_print(ANDROID_LOG_INFO, "HelloNDK!");

在我的C代码上

我在LogCat上找不到该输出.我需要设置哪种过滤器

I wouldn't find that output on my LogCat. What kind of filter I need to setup

按日志标签,按日志消息,按应用程序名称,按日志级别...等.

by Log Tag, by Log Message, by Application Name, by Log Level...etc.

推荐答案

您没有找到输出,因为您滥用了该函数.该函数具有原型:

You don't find output because you have misused the function. The function has the prototype:

int __android_log_print(int prio, const char *tag,  const char *fmt, ...);

因此,您必须提供标签"以及格式.

So you must supply a "tag" as well as the format.

例如

__android_log_print(ANDROID_LOG_INFO, "MyTag", "The value is %d", some_variable);

一旦正确使用了该函数,就可以像使用Java代码一样使用任何过滤方法(或根本不使用任何过滤方法,例如您可以从adb logcat命令获得而没有更多参数).

Once you use the function properly, you can use any filtering method (or none at all - such as you'd get from the adb logcat command without further arguments) just as with java code.

这篇关于Android NDK __android_log_print函数和LogCat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆