Android NDK __android_log_print function and LogCat
Asked Answered
I

1

17

I have a function like

__android_log_print(ANDROID_LOG_INFO, "HelloNDK!");

on my C code

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.

Insidious answered 23/5, 2013 at 18:2 Comment(0)
C
41

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.

For example

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

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.

Cavalcade answered 23/5, 2013 at 18:13 Comment(1)
Is the log printed in some file? Can we customise to print to a specific file?Muddleheaded

© 2022 - 2024 — McMap. All rights reserved.