Book

[안드로이드의 모든 것 NDK] SDK, NDK 로그 출력

BlueSwamp 2014. 3. 3. 00:22
반응형

1. SDK 로그 출력

Log.e(태그, 로그 메시지);

 에러 로그

 public static int e(String tag, String msg, Throwable tr) 

 public static int e(String tag, String msg)

 경고 로그

 public static int w(String tag, String msg, Throwable tr) 

 public static int w(String tag, String msg) 

 정보 로그

 public static int i(String tag, String msg, Throwable tr) 

 public static int i(String tag, String msg) 

 디버깅 로그

 public static int d(String tag, String msg, Throwable tr) 

 public static int d(String tag, String msg) 

 세부 정보 로그

 public static int v(String tag, String msg, Throwable tr) 

 public static int v(String tag, String msg)  


2. NDK 로그 출력

Log 버퍼의 크기가 작으므로 많은 양의 로그를 출력하면 로그가 안나오는 경우가 가끔 있다.

 __android_log_write

 간단한 문자열 출력 

 __android_log_print

 printf처럼 사용 

 __android_log_vprint

 va_list를 사용할 수 있음 

 __android_log_assert

 assert와 같음. 디버깅할 때 쓴다. 

Android.ml에 다음을 추가한다.

LOCAL_LDLIBS := -llog


사용 하려는 코드에는 log.h 파일을 포함 해준다.

#include <android/log.h>


원하는 곳에 다음 코드를 사용한다.

__android_log_print(ANDROID_LOG_INFO, "----", "AAAAAA");


지정 가능한 로그이 유형

ANDROID_LOG_UNKNOWN

ANDROID_LOG_DEFAULT

ANDROID_LOG_VERBOSE

ANDROID_LOG_INFO

ANDROID_LOG_WARN

ANDROID_LOG_ERROR

ANDROID_LOG_FATAL

ANDROID_LOG_SILENT



안드로이드의 모든 것 NDK 中


반응형