Skip to content

Most visited

Recently visited

navigation

log.h File Reference

log.h File Reference

Typedefs

typedef enum android_LogPriority android_LogPriority
 
typedef enum log_id log_id_t
 

Enumerations

enum  android_LogPriority {
  ANDROID_LOG_UNKNOWN = 0, ANDROID_LOG_DEFAULT, ANDROID_LOG_VERBOSE, ANDROID_LOG_DEBUG,
  ANDROID_LOG_INFO, ANDROID_LOG_WARN, ANDROID_LOG_ERROR, ANDROID_LOG_FATAL,
  ANDROID_LOG_SILENT
}
 
enum  log_id {
  LOG_ID_MIN = 0, LOG_ID_MAIN = 0, LOG_ID_RADIO = 1, LOG_ID_EVENTS = 2,
  LOG_ID_SYSTEM = 3, LOG_ID_CRASH = 4, LOG_ID_STATS = 5, LOG_ID_SECURITY = 6,
  LOG_ID_KERNEL = 7, LOG_ID_MAX
}
 

Functions

int __android_log_write (int prio, const char *tag, const char *text)
 
int __android_log_print (int prio, const char *tag, const char *fmt,...) __attribute__((__format__(gnu_printf
 
int __attribute__ ((__format__(printf, 3, 4))) __attribute__((__format__(printf
 
int int __android_log_vprint (int prio, const char *tag, const char *fmt, va_list ap) __attribute__((__format__(gnu_printf
 
int int __attribute__ ((__format__(printf, 3, 0))) __attribute__((__format__(printf
 
int int void __android_log_assert (const char *cond, const char *tag, const char *fmt,...) __attribute__((__noreturn__)) __attribute__((__format__(gnu_printf
 
int __android_log_buf_write (int bufID, int prio, const char *tag, const char *text)
 
int __android_log_buf_print (int bufID, int prio, const char *tag, const char *fmt,...) __attribute__((__format__(printf
 

Detailed Description

Support routines to send messages to the Android log buffer, which can later be accessed through the logcat utility.

Each log message must have

  • a priority
  • a log tag
  • some text

The tag normally corresponds to the component that emits the log message, and should be reasonably small.

Log message text may be truncated to less than an implementation-specific limit (1023 bytes).

Note that a newline character ("\n") will be appended automatically to your log message, if not already there. It is not possible to send several messages and have them appear on a single line in logcat.

Please use logging in moderation:

  • Sending log messages eats CPU and slow down your application and the system.
  • The circular log buffer is pretty small, so sending many messages will hide other important log messages.
  • In release builds, only send log messages to account for exceptional conditions.

Typedef Documentation

◆ android_LogPriority

Android log priority values, in increasing order of priority.

◆ log_id_t

typedef enum log_id log_id_t

Enumeration Type Documentation

◆ android_LogPriority

Android log priority values, in increasing order of priority.

Enumerator
ANDROID_LOG_UNKNOWN 

For internal use only.

ANDROID_LOG_DEFAULT 

The default priority, for internal use only.

ANDROID_LOG_VERBOSE 

Verbose logging. Should typically be disabled for a release apk.

ANDROID_LOG_DEBUG 

Debug logging. Should typically be disabled for a release apk.

ANDROID_LOG_INFO 

Informational logging. Should typically be disabled for a release apk.

ANDROID_LOG_WARN 

Warning logging. For use with recoverable failures.

ANDROID_LOG_ERROR 

Error logging. For use with unrecoverable failures.

ANDROID_LOG_FATAL 

Fatal logging. For use when aborting.

ANDROID_LOG_SILENT 

For internal use only.

◆ log_id

enum log_id
Enumerator
LOG_ID_MIN 
LOG_ID_MAIN 
LOG_ID_RADIO 
LOG_ID_EVENTS 
LOG_ID_SYSTEM 
LOG_ID_CRASH 
LOG_ID_STATS 
LOG_ID_SECURITY 
LOG_ID_KERNEL 
LOG_ID_MAX 

Function Documentation

◆ __android_log_assert()

int int void __android_log_assert ( const char *  cond,
const char *  tag,
const char *  fmt,
  ... 
)

Writes an assertion failure to the log (as ANDROID_LOG_FATAL) and to stderr, before calling abort(3).

If fmt is non-null, cond is unused. If fmt is null, the string Assertion failed: s is used with cond as the string argument. If both fmt and cond are null, a default string is provided.

Most callers should use assert(3) from <assert.h> instead, or the __assert and __assert2 functions provided by bionic if more control is needed. They support automatically including the source filename and line number more conveniently than this function.

◆ __android_log_buf_print()

int __android_log_buf_print ( int  bufID,
int  prio,
const char *  tag,
const char *  fmt,
  ... 
)

◆ __android_log_buf_write()

int __android_log_buf_write ( int  bufID,
int  prio,
const char *  tag,
const char *  text 
)

◆ __android_log_print()

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

Writes a formatted string to the log, with priority prio and tag tag. The details of formatting are the same as for printf(3).

◆ __android_log_vprint()

int int __android_log_vprint ( int  prio,
const char *  tag,
const char *  fmt,
va_list  ap 
)

Equivalent to __android_log_print, but taking a va_list. (If __android_log_print is like printf, this is like vprintf.)

◆ __android_log_write()

int __android_log_write ( int  prio,
const char *  tag,
const char *  text 
)

Writes the constant string text to the log, with priority prio and tag tag.

◆ __attribute__() [1/2]

int int void __attribute__ ( (__format__(printf, 3, 4))  )

◆ __attribute__() [2/2]

int int __attribute__ ( (__format__(printf, 3, 0))  )
This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (April 2018 — Developer Survey)