liblog: document the liblog<->logd protocol format
This protocol documentation is spread out among various functions where it is implemented. This change makes a single README.protocol.md file with a high level overview, referencing the struct names where useful. Test: n/a Change-Id: I83c9f484352b489b4a20cce241d92413f780f9ec
This commit is contained in:
parent
e05b78412b
commit
a379b1ce05
|
@ -0,0 +1,49 @@
|
|||
# liblog -> logd
|
||||
|
||||
The data that liblog sends to logd is represented below.
|
||||
|
||||
struct {
|
||||
android_log_header_t header;
|
||||
union {
|
||||
struct {
|
||||
char prio;
|
||||
char tag[...];
|
||||
char message[...];
|
||||
} string;
|
||||
struct {
|
||||
android_event_header_t event_header;
|
||||
android_event_*_t payload[...];
|
||||
} binary;
|
||||
};
|
||||
};
|
||||
|
||||
The payload, excluding the header, has a max size of LOGGER_ENTRY_MAX_PAYLOAD.
|
||||
|
||||
## header
|
||||
|
||||
The header is added immediately before sending the log message to logd.
|
||||
|
||||
## `string` payload
|
||||
|
||||
The `string` part of the union is for normal buffers (main, system, radio, etc) and consists of a
|
||||
single character priority, followed by a variable length null terminated string for the tag, and
|
||||
finally a variable length null terminated string for the message.
|
||||
|
||||
This payload is used for the `__android_log_buf_write()` family of functions.
|
||||
|
||||
## `binary` payload
|
||||
|
||||
The `binary` part of the union is for binary buffers (events, security, etc) and consists of an
|
||||
android_event_header_t struct followed by a variable number of android_event_*_t
|
||||
(android_event_list_t, android_event_int_t, etc) structs.
|
||||
|
||||
If multiple android_event_*_t elements are present, then they must be in a list and the first
|
||||
element in payload must be an android_event_list_t.
|
||||
|
||||
This payload is used for the `__android_log_bwrite()` family of functions. It is additionally used
|
||||
for `android_log_write_list()` and the related functions that manipulate event lists.
|
||||
|
||||
# logd -> liblog
|
||||
|
||||
logd sends a `logger_entry` struct to liblog followed by the payload. The payload is identical to
|
||||
the payloads defined above. The max size of the entire message from logd is LOGGER_ENTRY_MAX_LEN.
|
|
@ -148,24 +148,6 @@ static int logdWrite(log_id_t logId, struct timespec* ts, struct iovec* vec, siz
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* struct {
|
||||
* // what we provide to socket
|
||||
* android_log_header_t header;
|
||||
* // caller provides
|
||||
* union {
|
||||
* struct {
|
||||
* char prio;
|
||||
* char payload[];
|
||||
* } string;
|
||||
* struct {
|
||||
* uint32_t tag
|
||||
* char payload[];
|
||||
* } binary;
|
||||
* };
|
||||
* };
|
||||
*/
|
||||
|
||||
header.tid = gettid();
|
||||
header.realtime.tv_sec = ts->tv_sec;
|
||||
header.realtime.tv_nsec = ts->tv_nsec;
|
||||
|
|
Loading…
Reference in New Issue