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 20where the embedded structs are defined as: 21 22 struct android_log_header_t { 23 uint8_t id; 24 uint16_t tid; 25 log_time realtime; 26 }; 27 28 struct log_time { 29 uint32_t tv_sec = 0; 30 uint32_t tv_nsec = 0; 31 } 32 33 struct android_event_header_t { 34 int32_t tag; 35 }; 36 37 struct android_event_list_t { 38 int8_t type; // EVENT_TYPE_LIST 39 int8_t element_count; 40 }; 41 42 struct android_event_float_t { 43 int8_t type; // EVENT_TYPE_FLOAT 44 float data; 45 }; 46 47 struct android_event_int_t { 48 int8_t type; // EVENT_TYPE_INT 49 int32_t data; 50 } android_event_int_t; 51 52 struct android_event_long_t { 53 int8_t type; // EVENT_TYPE_LONG 54 int64_t data; 55 }; 56 57 struct android_event_string_t { 58 int8_t type; // EVENT_TYPE_STRING; 59 int32_t length; 60 char data[]; 61 }; 62 63The payload, excluding the header, has a max size of LOGGER_ENTRY_MAX_PAYLOAD. 64 65## header 66 67The header is added immediately before sending the log message to logd. 68 69## `string` payload 70 71The `string` part of the union is for normal buffers (main, system, radio, etc) and consists of a 72single character priority, followed by a variable length null terminated string for the tag, and 73finally a variable length null terminated string for the message. 74 75This payload is used for the `__android_log_buf_write()` family of functions. 76 77## `binary` payload 78 79The `binary` part of the union is for binary buffers (events, security, etc) and consists of an 80android_event_header_t struct followed by a variable number of android_event_*_t 81(android_event_list_t, android_event_int_t, etc) structs. 82 83If multiple android_event_*_t elements are present, then they must be in a list and the first 84element in payload must be an android_event_list_t. 85 86This payload is used for the `__android_log_bwrite()` family of functions. It is additionally used 87for `android_log_write_list()` and the related functions that manipulate event lists. 88 89# logd -> liblog 90 91logd sends a `logger_entry` struct to liblog followed by the payload. The payload is identical to 92the payloads defined above. The max size of the entire message from logd is LOGGER_ENTRY_MAX_LEN. 93