Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
include/ | 03-May-2024 | - | 2,282 | 1,155 | ||
include_vndk/ | 03-May-2024 | - | 1,082 | 566 | ||
tests/ | 03-May-2024 | - | 5,405 | 4,036 | ||
.clang-format | D | 03-May-2024 | 239 | |||
Android.bp | D | 03-May-2024 | 4 KiB | 155 | 144 | |
NOTICE | D | 03-May-2024 | 10.4 KiB | 191 | 158 | |
OWNERS | D | 03-May-2024 | 21 | 2 | 1 | |
README.md | D | 03-May-2024 | 7.6 KiB | 167 | 138 | |
README.protocol.md | D | 03-May-2024 | 1.7 KiB | 50 | 35 | |
event.logtags | D | 03-May-2024 | 1.2 KiB | 38 | 36 | |
event_tag_map.cpp | D | 03-May-2024 | 18.9 KiB | 649 | 509 | |
liblog.map.txt | D | 03-May-2024 | 2.6 KiB | 97 | 89 | |
log_event_list.cpp | D | 03-May-2024 | 16.5 KiB | 544 | 452 | |
log_event_write.cpp | D | 03-May-2024 | 1.4 KiB | 49 | 27 | |
log_time.cpp | D | 03-May-2024 | 4 KiB | 190 | 150 | |
logd_reader.cpp | D | 03-May-2024 | 8.5 KiB | 372 | 277 | |
logd_reader.h | D | 03-May-2024 | 916 | 32 | 9 | |
logd_writer.cpp | D | 03-May-2024 | 5.9 KiB | 196 | 128 | |
logd_writer.h | D | 03-May-2024 | 782 | 25 | 5 | |
logger.h | D | 03-May-2024 | 1.3 KiB | 52 | 21 | |
logger_name.cpp | D | 03-May-2024 | 1.9 KiB | 73 | 43 | |
logger_read.cpp | D | 03-May-2024 | 3.9 KiB | 150 | 100 | |
logger_write.cpp | D | 03-May-2024 | 13.8 KiB | 520 | 377 | |
logger_write.h | D | 03-May-2024 | 684 | 22 | 3 | |
logprint.cpp | D | 03-May-2024 | 50.1 KiB | 1,751 | 1,323 | |
pmsg_reader.cpp | D | 03-May-2024 | 13.2 KiB | 472 | 372 | |
pmsg_reader.h | D | 03-May-2024 | 851 | 30 | 8 | |
pmsg_writer.cpp | D | 03-May-2024 | 6.3 KiB | 248 | 159 | |
pmsg_writer.h | D | 03-May-2024 | 782 | 25 | 5 | |
properties.cpp | D | 03-May-2024 | 18.5 KiB | 668 | 499 | |
uio.h | D | 03-May-2024 | 763 | 28 | 10 |
README.md
1Android liblog 2-------------- 3 4Public Functions and Macros 5--------------------------- 6 7 /* 8 * Please limit to 24 characters for runtime is loggable, 9 * 16 characters for persist is loggable, and logcat pretty 10 * alignment with limit of 7 characters. 11 */ 12 #define LOG_TAG "yourtag" 13 #include <log/log.h> 14 15 ALOG(android_priority, tag, format, ...) 16 IF_ALOG(android_priority, tag) 17 LOG_PRI(priority, tag, format, ...) 18 LOG_PRI_VA(priority, tag, format, args) 19 #define LOG_TAG NULL 20 ALOGV(format, ...) 21 SLOGV(format, ...) 22 RLOGV(format, ...) 23 ALOGV_IF(cond, format, ...) 24 SLOGV_IF(cond, format, ...) 25 RLOGV_IF(cond, format, ...) 26 IF_ALOGC() 27 ALOGD(format, ...) 28 SLOGD(format, ...) 29 RLOGD(format, ...) 30 ALOGD_IF(cond, format, ...) 31 SLOGD_IF(cond, format, ...) 32 RLOGD_IF(cond, format, ...) 33 IF_ALOGD() 34 ALOGI(format, ...) 35 SLOGI(format, ...) 36 RLOGI(format, ...) 37 ALOGI_IF(cond, format, ...) 38 SLOGI_IF(cond, format, ...) 39 RLOGI_IF(cond, format, ...) 40 IF_ALOGI() 41 ALOGW(format, ...) 42 SLOGW(format, ...) 43 RLOGW(format, ...) 44 ALOGW_IF(cond, format, ...) 45 SLOGW_IF(cond, format, ...) 46 RLOGW_IF(cond, format, ...) 47 IF_ALOGW() 48 ALOGE(format, ...) 49 SLOGE(format, ...) 50 RLOGE(format, ...) 51 ALOGE_IF(cond, format, ...) 52 SLOGE_IF(cond, format, ...) 53 RLOGE_IF(cond, format, ...) 54 IF_ALOGE() 55 LOG_FATAL(format, ...) 56 LOG_ALWAYS_FATAL(format, ...) 57 LOG_FATAL_IF(cond, format, ...) 58 LOG_ALWAYS_FATAL_IF(cond, format, ...) 59 ALOG_ASSERT(cond, format, ...) 60 LOG_EVENT_INT(tag, value) 61 LOG_EVENT_LONG(tag, value) 62 63 clockid_t android_log_clockid() 64 65 log_id_t android_logger_get_id(struct logger *logger) 66 int android_logger_clear(struct logger *logger) 67 int android_logger_get_log_size(struct logger *logger) 68 int android_logger_get_log_readable_size(struct logger *logger) 69 int android_logger_get_log_version(struct logger *logger) 70 71 struct logger_list *android_logger_list_alloc(int mode, unsigned int tail, pid_t pid) 72 struct logger *android_logger_open(struct logger_list *logger_list, log_id_t id) 73 struct logger_list *android_logger_list_open(log_id_t id, int mode, unsigned int tail, pid_t pid) 74 int android_logger_list_read(struct logger_list *logger_list, struct log_msg *log_msg) 75 void android_logger_list_free(struct logger_list *logger_list) 76 77 log_id_t android_name_to_log_id(const char *logName) 78 const char *android_log_id_to_name(log_id_t log_id) 79 80 android_log_context create_android_logger(uint32_t tag) 81 82 int android_log_write_list_begin(android_log_context ctx) 83 int android_log_write_list_end(android_log_context ctx) 84 85 int android_log_write_int32(android_log_context ctx, int32_t value) 86 int android_log_write_int64(android_log_context ctx, int64_t value) 87 int android_log_write_string8(android_log_context ctx, const char *value) 88 int android_log_write_string8_len(android_log_context ctx, const char *value, size_t maxlen) 89 int android_log_write_float32(android_log_context ctx, float value) 90 91 int android_log_write_list(android_log_context ctx, log_id_t id = LOG_ID_EVENTS) 92 93 android_log_context create_android_log_parser(const char *msg, size_t len) 94 android_log_list_element android_log_read_next(android_log_context ctx) 95 android_log_list_element android_log_peek_next(android_log_context ctx) 96 97 int android_log_destroy(android_log_context *ctx) 98 99Description 100----------- 101 102liblog represents an interface to the volatile Android Logging system for NDK (Native) applications 103and libraries. Interfaces for either writing or reading logs. The log buffers are divided up in 104Main, System, Radio and Events sub-logs. 105 106The logging interfaces are a series of macros, all of which can be overridden individually in order 107to control the verbosity of the application or library. `[ASR]LOG[VDIWE]` calls are used to log to 108BAsic, System or Radio sub-logs in either the Verbose, Debug, Info, Warning or Error priorities. 109`[ASR]LOG[VDIWE]_IF` calls are used to perform thus based on a condition being true. 110`IF_ALOG[VDIWE]` calls are true if the current `LOG_TAG` is enabled at the specified priority. 111`LOG_ALWAYS_FATAL` is used to `ALOG` a message, then kill the process. `LOG_FATAL` call is a 112variant of `LOG_ALWAYS_FATAL`, only enabled in engineering, and not release builds. `ALOG_ASSERT` 113is used to `ALOG` a message if the condition is false; the condition is part of the logged message. 114`LOG_EVENT_(INT|LONG)` is used to drop binary content into the Events sub-log. 115 116The log reading interfaces permit opening the logs either singly or multiply, retrieving a log entry 117at a time in time sorted order, optionally limited to a specific pid and tail of the log(s) and 118finally a call closing the logs. A single log can be opened with `android_logger_list_open()`; or 119multiple logs can be opened with `android_logger_list_alloc()`, calling in turn the 120`android_logger_open()` for each log id. Each entry can be retrieved with 121`android_logger_list_read()`. The log(s) can be closed with `android_logger_list_free()`. The logs 122should be opened with an `ANDROID_LOG_RDONLY` mode. `ANDROID_LOG_NONBLOCK` mode will report when 123the log reading is done with an `EAGAIN` error return code, otherwise the 124`android_logger_list_read()` call will block for new entries. 125 126The `ANDROID_LOG_WRAP` mode flag to the `android_logger_list_alloc_time()` signals logd to quiesce 127the reader until the buffer is about to prune at the start time then proceed to dumping content. 128 129The `ANDROID_LOG_PSTORE` mode flag to the `android_logger_open()` is used to switch from the active 130logs to the persistent logs from before the last reboot. 131 132The value returned by `android_logger_open()` can be used as a parameter to the 133`android_logger_clear()` function to empty the sub-log. It is recommended to only open log 134`ANDROID_LOG_WRONLY` in that case. 135 136The value returned by `android_logger_open()` can be used as a parameter to the 137`android_logger_get_log_(size|readable_size|version)` to retrieve the sub-log maximum size, readable 138size and log buffer format protocol version respectively. `android_logger_get_id()` returns the id 139that was used when opening the sub-log. It is recommended to open the log `ANDROID_LOG_RDONLY` in 140these cases. 141 142Errors 143------ 144 145If messages fail, a negative error code will be returned to the caller. 146 147The `-ENOTCONN` return code indicates that the logger daemon is stopped. 148 149The `-EBADF` return code indicates that the log access point can not be opened, or the log buffer id 150is out of range. 151 152For the `-EAGAIN` return code, this means that the logging message was temporarily backed-up either 153because of Denial Of Service (DOS) logging pressure from some chatty application or service in the 154Android system, or if too small of a value is set in /proc/sys/net/unix/max_dgram_qlen. To aid in 155diagnosing the occurence of this, a binary event from liblog will be sent to the log daemon once a 156new message can get through indicating how many messages were dropped as a result. Please take 157action to resolve the structural problems at the source. 158 159It is generally not advised for the caller to retry the `-EAGAIN` return code as this will only make 160the problem(s) worse and cause your application to temporarily drop to the logger daemon priority, 161BATCH scheduling policy and background task cgroup. If you require a group of messages to be passed 162atomically, merge them into one message with embedded newlines to the maximum length 163`LOGGER_ENTRY_MAX_PAYLOAD`. 164 165Other return codes from writing operation can be returned. Since the library retries on `EINTR`, 166`-EINTR` should never be returned. 167
README.protocol.md
1# liblog -> logd 2 3The data that liblog sends to logd is represented below. 4 5 struct { 6 android_log_header_t header; 7 union { 8 struct { 9 char prio; 10 char tag[...]; 11 char message[...]; 12 } string; 13 struct { 14 android_event_header_t event_header; 15 android_event_*_t payload[...]; 16 } binary; 17 }; 18 }; 19 20The payload, excluding the header, has a max size of LOGGER_ENTRY_MAX_PAYLOAD. 21 22## header 23 24The header is added immediately before sending the log message to logd. 25 26## `string` payload 27 28The `string` part of the union is for normal buffers (main, system, radio, etc) and consists of a 29single character priority, followed by a variable length null terminated string for the tag, and 30finally a variable length null terminated string for the message. 31 32This payload is used for the `__android_log_buf_write()` family of functions. 33 34## `binary` payload 35 36The `binary` part of the union is for binary buffers (events, security, etc) and consists of an 37android_event_header_t struct followed by a variable number of android_event_*_t 38(android_event_list_t, android_event_int_t, etc) structs. 39 40If multiple android_event_*_t elements are present, then they must be in a list and the first 41element in payload must be an android_event_list_t. 42 43This payload is used for the `__android_log_bwrite()` family of functions. It is additionally used 44for `android_log_write_list()` and the related functions that manipulate event lists. 45 46# logd -> liblog 47 48logd sends a `logger_entry` struct to liblog followed by the payload. The payload is identical to 49the payloads defined above. The max size of the entire message from logd is LOGGER_ENTRY_MAX_LEN. 50