1 LIBLOG(3) Android NDK Programming Manual LIBLOG(3) 2 3 4 5 NAME 6 liblog - Android NDK logger interfaces 7 8 SYNOPSIS 9 #include <log/log.h> 10 11 ALOG(android_priority, tag, format, ...) 12 IF_ALOG(android_priority, tag) 13 LOG_PRI(priority, tag, format, ...) 14 LOG_PRI_VA(priority, tag, format, args) 15 #define LOG_TAG NULL 16 ALOGV(format, ...) 17 SLOGV(format, ...) 18 RLOGV(format, ...) 19 ALOGV_IF(cond, format, ...) 20 SLOGV_IF(cond, format, ...) 21 RLOGV_IF(cond, format, ...) 22 IF_ALOGC() 23 ALOGD(format, ...) 24 SLOGD(format, ...) 25 RLOGD(format, ...) 26 ALOGD_IF(cond, format, ...) 27 SLOGD_IF(cond, format, ...) 28 RLOGD_IF(cond, format, ...) 29 IF_ALOGD() 30 ALOGI(format, ...) 31 SLOGI(format, ...) 32 RLOGI(format, ...) 33 ALOGI_IF(cond, format, ...) 34 SLOGI_IF(cond, format, ...) 35 RLOGI_IF(cond, format, ...) 36 IF_ALOGI() 37 ALOGW(format, ...) 38 SLOGW(format, ...) 39 RLOGW(format, ...) 40 ALOGW_IF(cond, format, ...) 41 SLOGW_IF(cond, format, ...) 42 RLOGW_IF(cond, format, ...) 43 IF_ALOGW() 44 ALOGE(format, ...) 45 SLOGE(format, ...) 46 RLOGE(format, ...) 47 ALOGE_IF(cond, format, ...) 48 SLOGE_IF(cond, format, ...) 49 RLOGE_IF(cond, format, ...) 50 IF_ALOGE() 51 LOG_FATAL(format, ...) 52 LOG_ALWAYS_FATAL(format, ...) 53 LOG_FATAL_IF(cond, format, ...) 54 LOG_ALWAYS_FATAL_IF(cond, format, ...) 55 ALOG_ASSERT(cond, format, ...) 56 LOG_EVENT_INT(tag, value) 57 LOG_EVENT_LONG(tag, value) 58 59 Link with -llog 60 61 #include <log/logger.h> 62 63 log_id_t android_logger_get_id(struct logger *logger) 64 int android_logger_clear(struct logger *logger) 65 int android_logger_get_log_size(struct logger *logger) 66 int android_logger_get_log_readable_size(struct logger *logger) 67 int android_logger_get_log_version(struct logger *logger) 68 69 struct logger_list *android_logger_list_alloc(int mode, unsigned int 70 tail, pid_t pid) 71 struct logger *android_logger_open(struct logger_list *logger_list, 72 log_id_t id) 73 struct logger_list *android_logger_list_open(log_id_t id, int mode, 74 unsigned int tail, pid_t pid) 75 76 int android_logger_list_read(struct logger_list *logger_list, struct 77 log_msg *log_msg 78 79 void android_logger_list_free(struct logger_list *logger_list) 80 81 log_id_t android_name_to_log_id(const char *logName) 82 const char *android_log_id_to_name(log_id_t log_id) 83 84 Link with -llog 85 86 DESCRIPTION 87 liblog represents an interface to the volatile Android Logging system 88 for NDK (Native) applications and libraries. Interfaces for either 89 writing or reading logs. The log buffers are divided up in Main, Sys 90 tem, Radio and Events sub-logs. 91 92 The logging interfaces are a series of macros, all of which can be 93 overridden individually in order to control the verbosity of the appli 94 cation or library. [ASR]LOG[VDIWE] calls are used to log to BAsic, 95 System or Radio sub-logs in either the Verbose, Debug, Info, Warning or 96 Error priorities. [ASR]LOG[VDIWE]_IF calls are used to perform thus 97 based on a condition being true. IF_ALOG[VDIWE] calls are true if the 98 current LOG_TAG is enabled at the specified priority. LOG_ALWAYS_FATAL 99 is used to ALOG a message, then kill the process. LOG_FATAL call is a 100 variant of LOG_ALWAYS_FATAL, only enabled in engineering, and not 101 release builds. ALOG_ASSERT is used to ALOG a message if the condition 102 is false; the condition is part of the logged message. 103 LOG_EVENT_(INT|LONG) is used to drop binary content into the Events 104 sub-log. 105 106 The log reading interfaces permit opening the logs either singly or 107 multiply, retrieving a log entry at a time in time sorted order, 108 optionally limited to a specific pid and tail of the log(s) and finally 109 a call closing the logs. A single log can be opened with android_log 110 ger_list_open; or multiple logs can be opened with android_log 111 ger_list_alloc, calling in turn the android_logger_open for each log 112 id. Each entry can be retrieved with android_logger_list_read. The 113 log(s) can be closed with android_logger_list_free. The logs should be 114 opened with an O_RDONLY mode. O_NDELAY mode will report when the log 115 reading is done with an EAGAIN error return code, otherwise the 116 android_logger_list_read call will block for new entries. 117 118 The value returned by android_logger_open can be used as a parameter to 119 the android_logger_clear function to empty the sub-log. It is recom 120 mended to only open log O_WRONLY. 121 122 The value returned by android_logger_open can be used as a parameter to 123 the android_logger_get_log_(size|readable_size|version) to retrieve the 124 sub-log maximum size, readable size and log buffer format protocol ver 125 sion respectively. android_logger_get_id returns the id that was used 126 when opening the sub-log. It is recommended to open the log O_RDONLY 127 in these cases. 128 129 SEE ALSO 130 syslogd(8) 131 132 133 134 17 Dec 2013 LIBLOG(3) 135