Native equivalent to Log.v?

58 views
Skip to first unread message

Felipe Monteiro de Carvalho

unread,
Jan 13, 2011, 4:31:51 AM1/13/11
to android-ndk
Hello,

I am trying to trace an issue in my native executable, but I lack
appropriate logging capabilities. Is there a native equivalent to
Log.v? This way I could see both logs, from Java and from the Pascal
applications in the same adb logcat =)

thanks,

Olivier Guilyardi

unread,
Jan 13, 2011, 6:37:23 AM1/13/11
to andro...@googlegroups.com

Yep, there is. Look into <android/log.h>.

--
Olivier

eyal zmora

unread,
Jan 13, 2011, 6:15:50 AM1/13/11
to andro...@googlegroups.com
You can use one of these methods:
int __android_log_write(int prio, const char *tag, const char *text);
int __android_log_print(int prio, const char *tag,  const char *fmt, ...);
 
where 'prio' can be one of the following:
 ANDROID_LOG_UNKNOWN = 0,
    ANDROID_LOG_DEFAULT,    /* only for SetMinPriority() */
    ANDROID_LOG_VERBOSE,
    ANDROID_LOG_DEBUG,
    ANDROID_LOG_INFO,
    ANDROID_LOG_WARN,
    ANDROID_LOG_ERROR,
    ANDROID_LOG_FATAL,
    ANDROID_LOG_SILENT,  
 
Don't forget to add:  #include<android/log.h>
 
Eyal

2011/1/13 Felipe Monteiro de Carvalho <felipemonte...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.

Felipe Monteiro de Carvalho

unread,
Jan 13, 2011, 9:51:40 AM1/13/11
to android-ndk
Thanks a lot!

Two things, however:

1> Are there online docs on this routine? Google didn't help on that

2> On which shared object are these functions located? My application
is written in Pascal, so I need to declare the function as external
and then link to the appropriate shared object.

thanks,
FMdC

alan

unread,
Jan 13, 2011, 10:33:40 AM1/13/11
to android-ndk
most of the ndk is doucmented in the docs directory of the ndk
distribution. in this case stable-apis.html states:

Android-specific Log Support:
-----------------------------

<android/log.h> contains various definitions that can be used to send
log
messages to the kernel from your native code. Please have a look at
its
content in (build/platforms/android-3/common/include/android/log.h),
which
contain many informative comments on how to use it.

You should be able to write helpful wrapper macros for your own usage
to
access this facility.

If you use it, your native module should link to /system/lib/liblog.so
with:

LOCAL_LDLIBS := -llog


On Jan 13, 2:51 pm, Felipe Monteiro de Carvalho

Felipe Monteiro de Carvalho

unread,
Jan 13, 2011, 11:23:37 AM1/13/11
to android-ndk
Ok, thanks a lot for the answers =)

By the way, I found that someone had already made a Pascal binding to
this unit, just in case someone searches the archives in the future
the file can be found here:

http://lazarus-ccr.svn.sourceforge.net/viewvc/lazarus-ccr/bindings/android-ndk/log.pas?revision=1437&view=markup

thanks again,
FMdC
Reply all
Reply to author
Forward
0 new messages