logcat可以用于在Android中记录NDK代码吗?还是NDK的日志选项是什么? [英] Can logcat be used to log NDK code in Android? Or what are logging options from NDK?

查看:53
本文介绍了logcat可以用于在Android中记录NDK代码吗?还是NDK的日志选项是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个人如何从Android(NDK)的本机代码内部写入日志?有哪些可用选项? 例如,可以从NDK内部使用logcat编写日志吗?还是因为它在android中更高级,所以无法从NDK进行访问?

How would one write logs from inside Native code in Android (NDK)? What are the available options? For example, can logcat be used from inside of NDK to write logs? Or since its more upper level in android, it can not be accessible from NDK?

目前,我只知道使用以下代码从C代码编写时间: millis = System.currentTimeMillis();

At the moment I am just aware of writing times from C code with: millis = System.currentTimeMillis();

并且具有将这次写入的功能以及所有消息写入自定义日志文件的功能.

And with function that would write this time plus any messages to a custom log file.

推荐答案

您可以使用Android日志记录

You can use the Android logging

#include <android/log.h>

#define APPNAME "MyApp"

__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "My Log");

还要确保您还链接到Android.mk文件中的日志记录库:

Also Make sure you also link against the logging library, in your Android.mk file:

LOCAL_LDLIBS := -llog

已经在中进行了讨论登录Android NDK代码?

这篇关于logcat可以用于在Android中记录NDK代码吗?还是NDK的日志选项是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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