Merge changes I598c8c5c,I672b0f4d,Id882978b,Idff5e080,Ib124eca1, ...
* changes: logger.h: reduce maximum payload so sum is page size liblog: test for maximum payload can not survive change liblog: logprint use uid name if length less then 5 liblog: logprint add uid format modifier liblog: readlog apps get logger_entry_v4 for pstore logd: readlog apps get logger_entry_v4 logger.h: Add definition for logger_entry_v4
This commit is contained in:
commit
30edbdce9b
9 changed files with 108 additions and 35 deletions
|
|
@ -64,12 +64,24 @@ struct logger_entry_v3 {
|
||||||
char msg[0]; /* the entry's payload */
|
char msg[0]; /* the entry's payload */
|
||||||
} __attribute__((__packed__));
|
} __attribute__((__packed__));
|
||||||
|
|
||||||
|
struct logger_entry_v4 {
|
||||||
|
uint16_t len; /* length of the payload */
|
||||||
|
uint16_t hdr_size; /* sizeof(struct logger_entry_v4) */
|
||||||
|
int32_t pid; /* generating process's pid */
|
||||||
|
uint32_t tid; /* generating process's tid */
|
||||||
|
uint32_t sec; /* seconds since Epoch */
|
||||||
|
uint32_t nsec; /* nanoseconds */
|
||||||
|
uint32_t lid; /* log id of the payload, bottom 4 bits currently */
|
||||||
|
uint32_t uid; /* generating process's uid */
|
||||||
|
char msg[0]; /* the entry's payload */
|
||||||
|
} __attribute__((__packed__));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The maximum size of the log entry payload that can be
|
* The maximum size of the log entry payload that can be
|
||||||
* written to the logger. An attempt to write more than
|
* written to the logger. An attempt to write more than
|
||||||
* this amount will result in a truncated log entry.
|
* this amount will result in a truncated log entry.
|
||||||
*/
|
*/
|
||||||
#define LOGGER_ENTRY_MAX_PAYLOAD 4076
|
#define LOGGER_ENTRY_MAX_PAYLOAD 4068
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The maximum size of a log entry which can be read from the
|
* The maximum size of a log entry which can be read from the
|
||||||
|
|
@ -83,7 +95,8 @@ struct logger_entry_v3 {
|
||||||
struct log_msg {
|
struct log_msg {
|
||||||
union {
|
union {
|
||||||
unsigned char buf[LOGGER_ENTRY_MAX_LEN + 1];
|
unsigned char buf[LOGGER_ENTRY_MAX_LEN + 1];
|
||||||
struct logger_entry_v3 entry;
|
struct logger_entry_v4 entry;
|
||||||
|
struct logger_entry_v4 entry_v4;
|
||||||
struct logger_entry_v3 entry_v3;
|
struct logger_entry_v3 entry_v3;
|
||||||
struct logger_entry_v2 entry_v2;
|
struct logger_entry_v2 entry_v2;
|
||||||
struct logger_entry entry_v1;
|
struct logger_entry entry_v1;
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ typedef enum {
|
||||||
FORMAT_MODIFIER_ZONE, /* Adds zone to date */
|
FORMAT_MODIFIER_ZONE, /* Adds zone to date */
|
||||||
FORMAT_MODIFIER_EPOCH, /* Print time as seconds since Jan 1 1970 */
|
FORMAT_MODIFIER_EPOCH, /* Print time as seconds since Jan 1 1970 */
|
||||||
FORMAT_MODIFIER_MONOTONIC, /* Print cpu time as seconds since start */
|
FORMAT_MODIFIER_MONOTONIC, /* Print cpu time as seconds since start */
|
||||||
|
FORMAT_MODIFIER_UID, /* Adds uid */
|
||||||
} AndroidLogPrintFormat;
|
} AndroidLogPrintFormat;
|
||||||
|
|
||||||
typedef struct AndroidLogFormat_t AndroidLogFormat;
|
typedef struct AndroidLogFormat_t AndroidLogFormat;
|
||||||
|
|
@ -52,6 +53,7 @@ typedef struct AndroidLogEntry_t {
|
||||||
time_t tv_sec;
|
time_t tv_sec;
|
||||||
long tv_nsec;
|
long tv_nsec;
|
||||||
android_LogPriority priority;
|
android_LogPriority priority;
|
||||||
|
int32_t uid;
|
||||||
int32_t pid;
|
int32_t pid;
|
||||||
int32_t tid;
|
int32_t tid;
|
||||||
const char * tag;
|
const char * tag;
|
||||||
|
|
|
||||||
|
|
@ -634,6 +634,7 @@ static int android_logger_list_read_pstore(struct logger_list *logger_list,
|
||||||
android_log_header_t l;
|
android_log_header_t l;
|
||||||
} buf;
|
} buf;
|
||||||
static uint8_t preread_count;
|
static uint8_t preread_count;
|
||||||
|
bool is_system;
|
||||||
|
|
||||||
memset(log_msg, 0, sizeof(*log_msg));
|
memset(log_msg, 0, sizeof(*log_msg));
|
||||||
|
|
||||||
|
|
@ -690,12 +691,15 @@ static int android_logger_list_read_pstore(struct logger_list *logger_list,
|
||||||
}
|
}
|
||||||
|
|
||||||
uid = get_best_effective_uid();
|
uid = get_best_effective_uid();
|
||||||
if (!uid_has_log_permission(uid) && (uid != buf.p.uid)) {
|
is_system = uid_has_log_permission(uid);
|
||||||
|
if (!is_system && (uid != buf.p.uid)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = TEMP_FAILURE_RETRY(read(logger_list->sock,
|
ret = TEMP_FAILURE_RETRY(read(logger_list->sock,
|
||||||
log_msg->entry_v3.msg,
|
is_system ?
|
||||||
|
log_msg->entry_v4.msg :
|
||||||
|
log_msg->entry_v3.msg,
|
||||||
buf.p.len - sizeof(buf)));
|
buf.p.len - sizeof(buf)));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
@ -704,13 +708,18 @@ static int android_logger_list_read_pstore(struct logger_list *logger_list,
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_msg->entry_v3.len = buf.p.len - sizeof(buf);
|
log_msg->entry_v4.len = buf.p.len - sizeof(buf);
|
||||||
log_msg->entry_v3.hdr_size = sizeof(log_msg->entry_v3);
|
log_msg->entry_v4.hdr_size = is_system ?
|
||||||
log_msg->entry_v3.pid = buf.p.pid;
|
sizeof(log_msg->entry_v4) :
|
||||||
log_msg->entry_v3.tid = buf.l.tid;
|
sizeof(log_msg->entry_v3);
|
||||||
log_msg->entry_v3.sec = buf.l.realtime.tv_sec;
|
log_msg->entry_v4.pid = buf.p.pid;
|
||||||
log_msg->entry_v3.nsec = buf.l.realtime.tv_nsec;
|
log_msg->entry_v4.tid = buf.l.tid;
|
||||||
log_msg->entry_v3.lid = buf.l.id;
|
log_msg->entry_v4.sec = buf.l.realtime.tv_sec;
|
||||||
|
log_msg->entry_v4.nsec = buf.l.realtime.tv_nsec;
|
||||||
|
log_msg->entry_v4.lid = buf.l.id;
|
||||||
|
if (is_system) {
|
||||||
|
log_msg->entry_v4.uid = buf.p.uid;
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@
|
||||||
#include <cutils/list.h>
|
#include <cutils/list.h>
|
||||||
#include <log/logd.h>
|
#include <log/logd.h>
|
||||||
#include <log/logprint.h>
|
#include <log/logprint.h>
|
||||||
|
#include <private/android_filesystem_config.h>
|
||||||
|
|
||||||
#define MS_PER_NSEC 1000000
|
#define MS_PER_NSEC 1000000
|
||||||
#define US_PER_NSEC 1000
|
#define US_PER_NSEC 1000
|
||||||
|
|
@ -56,6 +57,7 @@ struct AndroidLogFormat_t {
|
||||||
bool zone_output;
|
bool zone_output;
|
||||||
bool epoch_output;
|
bool epoch_output;
|
||||||
bool monotonic_output;
|
bool monotonic_output;
|
||||||
|
bool uid_output;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -204,6 +206,7 @@ AndroidLogFormat *android_log_format_new()
|
||||||
p_ret->zone_output = false;
|
p_ret->zone_output = false;
|
||||||
p_ret->epoch_output = false;
|
p_ret->epoch_output = false;
|
||||||
p_ret->monotonic_output = android_log_clockid() == CLOCK_MONOTONIC;
|
p_ret->monotonic_output = android_log_clockid() == CLOCK_MONOTONIC;
|
||||||
|
p_ret->uid_output = false;
|
||||||
|
|
||||||
return p_ret;
|
return p_ret;
|
||||||
}
|
}
|
||||||
|
|
@ -258,6 +261,9 @@ int android_log_setPrintFormat(AndroidLogFormat *p_format,
|
||||||
case FORMAT_MODIFIER_MONOTONIC:
|
case FORMAT_MODIFIER_MONOTONIC:
|
||||||
p_format->monotonic_output = true;
|
p_format->monotonic_output = true;
|
||||||
return 0;
|
return 0;
|
||||||
|
case FORMAT_MODIFIER_UID:
|
||||||
|
p_format->uid_output = true;
|
||||||
|
return 0;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -290,6 +296,7 @@ AndroidLogPrintFormat android_log_formatFromString(const char * formatString)
|
||||||
else if (strcmp(formatString, "zone") == 0) format = FORMAT_MODIFIER_ZONE;
|
else if (strcmp(formatString, "zone") == 0) format = FORMAT_MODIFIER_ZONE;
|
||||||
else if (strcmp(formatString, "epoch") == 0) format = FORMAT_MODIFIER_EPOCH;
|
else if (strcmp(formatString, "epoch") == 0) format = FORMAT_MODIFIER_EPOCH;
|
||||||
else if (strcmp(formatString, "monotonic") == 0) format = FORMAT_MODIFIER_MONOTONIC;
|
else if (strcmp(formatString, "monotonic") == 0) format = FORMAT_MODIFIER_MONOTONIC;
|
||||||
|
else if (strcmp(formatString, "uid") == 0) format = FORMAT_MODIFIER_UID;
|
||||||
else {
|
else {
|
||||||
extern char *tzname[2];
|
extern char *tzname[2];
|
||||||
static const char gmt[] = "GMT";
|
static const char gmt[] = "GMT";
|
||||||
|
|
@ -451,6 +458,7 @@ int android_log_processLogBuffer(struct logger_entry *buf,
|
||||||
{
|
{
|
||||||
entry->tv_sec = buf->sec;
|
entry->tv_sec = buf->sec;
|
||||||
entry->tv_nsec = buf->nsec;
|
entry->tv_nsec = buf->nsec;
|
||||||
|
entry->uid = -1;
|
||||||
entry->pid = buf->pid;
|
entry->pid = buf->pid;
|
||||||
entry->tid = buf->tid;
|
entry->tid = buf->tid;
|
||||||
|
|
||||||
|
|
@ -482,6 +490,9 @@ int android_log_processLogBuffer(struct logger_entry *buf,
|
||||||
struct logger_entry_v2 *buf2 = (struct logger_entry_v2 *)buf;
|
struct logger_entry_v2 *buf2 = (struct logger_entry_v2 *)buf;
|
||||||
if (buf2->hdr_size) {
|
if (buf2->hdr_size) {
|
||||||
msg = ((char *)buf2) + buf2->hdr_size;
|
msg = ((char *)buf2) + buf2->hdr_size;
|
||||||
|
if (buf2->hdr_size >= sizeof(struct logger_entry_v4)) {
|
||||||
|
entry->uid = ((struct logger_entry_v4 *)buf)->uid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (i = 1; i < buf->len; i++) {
|
for (i = 1; i < buf->len; i++) {
|
||||||
if (msg[i] == '\0') {
|
if (msg[i] == '\0') {
|
||||||
|
|
@ -734,6 +745,7 @@ int android_log_processBinaryLogBuffer(struct logger_entry *buf,
|
||||||
entry->tv_sec = buf->sec;
|
entry->tv_sec = buf->sec;
|
||||||
entry->tv_nsec = buf->nsec;
|
entry->tv_nsec = buf->nsec;
|
||||||
entry->priority = ANDROID_LOG_INFO;
|
entry->priority = ANDROID_LOG_INFO;
|
||||||
|
entry->uid = -1;
|
||||||
entry->pid = buf->pid;
|
entry->pid = buf->pid;
|
||||||
entry->tid = buf->tid;
|
entry->tid = buf->tid;
|
||||||
|
|
||||||
|
|
@ -744,6 +756,9 @@ int android_log_processBinaryLogBuffer(struct logger_entry *buf,
|
||||||
struct logger_entry_v2 *buf2 = (struct logger_entry_v2 *)buf;
|
struct logger_entry_v2 *buf2 = (struct logger_entry_v2 *)buf;
|
||||||
if (buf2->hdr_size) {
|
if (buf2->hdr_size) {
|
||||||
eventData = ((unsigned char *)buf2) + buf2->hdr_size;
|
eventData = ((unsigned char *)buf2) + buf2->hdr_size;
|
||||||
|
if (buf2->hdr_size >= sizeof(struct logger_entry_v4)) {
|
||||||
|
entry->uid = ((struct logger_entry_v4 *)buf)->uid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
inCount = buf->len;
|
inCount = buf->len;
|
||||||
if (inCount < 4)
|
if (inCount < 4)
|
||||||
|
|
@ -1238,7 +1253,7 @@ char *android_log_formatLogLine (
|
||||||
char prefixBuf[128], suffixBuf[128];
|
char prefixBuf[128], suffixBuf[128];
|
||||||
char priChar;
|
char priChar;
|
||||||
int prefixSuffixIsHeaderFooter = 0;
|
int prefixSuffixIsHeaderFooter = 0;
|
||||||
char *ret = NULL;
|
char *ret;
|
||||||
time_t now;
|
time_t now;
|
||||||
unsigned long nsec;
|
unsigned long nsec;
|
||||||
|
|
||||||
|
|
@ -1310,6 +1325,30 @@ char *android_log_formatLogLine (
|
||||||
suffixLen = MIN(suffixLen, sizeof(suffixBuf));
|
suffixLen = MIN(suffixLen, sizeof(suffixBuf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char uid[16];
|
||||||
|
uid[0] = '\0';
|
||||||
|
if (p_format->uid_output) {
|
||||||
|
if (entry->uid >= 0) {
|
||||||
|
const struct android_id_info *info = android_ids;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < android_id_count; ++i) {
|
||||||
|
if (info->aid == (unsigned int)entry->uid) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++info;
|
||||||
|
}
|
||||||
|
if ((i < android_id_count) && (strlen(info->name) <= 5)) {
|
||||||
|
snprintf(uid, sizeof(uid), "%5s:", info->name);
|
||||||
|
} else {
|
||||||
|
// Not worth parsing package list, names all longer than 5
|
||||||
|
snprintf(uid, sizeof(uid), "%5d:", entry->uid);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
snprintf(uid, sizeof(uid), " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (p_format->format) {
|
switch (p_format->format) {
|
||||||
case FORMAT_TAG:
|
case FORMAT_TAG:
|
||||||
len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
|
len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
|
||||||
|
|
@ -1322,11 +1361,11 @@ char *android_log_formatLogLine (
|
||||||
" (%s)\n", entry->tag);
|
" (%s)\n", entry->tag);
|
||||||
suffixLen += MIN(len, sizeof(suffixBuf) - suffixLen);
|
suffixLen += MIN(len, sizeof(suffixBuf) - suffixLen);
|
||||||
len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
|
len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
|
||||||
"%c(%5d) ", priChar, entry->pid);
|
"%c(%s%5d) ", priChar, uid, entry->pid);
|
||||||
break;
|
break;
|
||||||
case FORMAT_THREAD:
|
case FORMAT_THREAD:
|
||||||
len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
|
len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
|
||||||
"%c(%5d:%5d) ", priChar, entry->pid, entry->tid);
|
"%c(%s%5d:%5d) ", priChar, uid, entry->pid, entry->tid);
|
||||||
strcpy(suffixBuf + suffixLen, "\n");
|
strcpy(suffixBuf + suffixLen, "\n");
|
||||||
++suffixLen;
|
++suffixLen;
|
||||||
break;
|
break;
|
||||||
|
|
@ -1338,21 +1377,26 @@ char *android_log_formatLogLine (
|
||||||
break;
|
break;
|
||||||
case FORMAT_TIME:
|
case FORMAT_TIME:
|
||||||
len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
|
len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
|
||||||
"%s %c/%-8s(%5d): ", timeBuf, priChar, entry->tag, entry->pid);
|
"%s %c/%-8s(%s%5d): ", timeBuf, priChar, entry->tag,
|
||||||
|
uid, entry->pid);
|
||||||
strcpy(suffixBuf + suffixLen, "\n");
|
strcpy(suffixBuf + suffixLen, "\n");
|
||||||
++suffixLen;
|
++suffixLen;
|
||||||
break;
|
break;
|
||||||
case FORMAT_THREADTIME:
|
case FORMAT_THREADTIME:
|
||||||
|
ret = strchr(uid, ':');
|
||||||
|
if (ret) {
|
||||||
|
*ret = ' ';
|
||||||
|
}
|
||||||
len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
|
len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
|
||||||
"%s %5d %5d %c %-8s: ", timeBuf,
|
"%s %s%5d %5d %c %-8s: ", timeBuf,
|
||||||
entry->pid, entry->tid, priChar, entry->tag);
|
uid, entry->pid, entry->tid, priChar, entry->tag);
|
||||||
strcpy(suffixBuf + suffixLen, "\n");
|
strcpy(suffixBuf + suffixLen, "\n");
|
||||||
++suffixLen;
|
++suffixLen;
|
||||||
break;
|
break;
|
||||||
case FORMAT_LONG:
|
case FORMAT_LONG:
|
||||||
len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
|
len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
|
||||||
"[ %s %5d:%5d %c/%-8s ]\n",
|
"[ %s %s%5d:%5d %c/%-8s ]\n",
|
||||||
timeBuf, entry->pid, entry->tid, priChar, entry->tag);
|
timeBuf, uid, entry->pid, entry->tid, priChar, entry->tag);
|
||||||
strcpy(suffixBuf + suffixLen, "\n\n");
|
strcpy(suffixBuf + suffixLen, "\n\n");
|
||||||
suffixLen += 2;
|
suffixLen += 2;
|
||||||
prefixSuffixIsHeaderFooter = 1;
|
prefixSuffixIsHeaderFooter = 1;
|
||||||
|
|
@ -1360,7 +1404,7 @@ char *android_log_formatLogLine (
|
||||||
case FORMAT_BRIEF:
|
case FORMAT_BRIEF:
|
||||||
default:
|
default:
|
||||||
len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
|
len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
|
||||||
"%c/%-8s(%5d): ", priChar, entry->tag, entry->pid);
|
"%c/%-8s(%s%5d): ", priChar, entry->tag, uid, entry->pid);
|
||||||
strcpy(suffixBuf + suffixLen, "\n");
|
strcpy(suffixBuf + suffixLen, "\n");
|
||||||
++suffixLen;
|
++suffixLen;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -342,8 +342,9 @@ TEST(liblog, android_logger_list_read__cpu) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char max_payload_tag[] = "TEST_max_payload_XXXX";
|
static const char max_payload_tag[] = "TEST_max_payload_XXXX";
|
||||||
static const char max_payload_buf[LOGGER_ENTRY_MAX_PAYLOAD
|
#define SIZEOF_MAX_PAYLOAD_BUF (LOGGER_ENTRY_MAX_PAYLOAD - \
|
||||||
- sizeof(max_payload_tag) - 1] = "LEONATO\n\
|
sizeof(max_payload_tag) - 1)
|
||||||
|
static const char max_payload_buf[] = "LEONATO\n\
|
||||||
I learn in this letter that Don Peter of Arragon\n\
|
I learn in this letter that Don Peter of Arragon\n\
|
||||||
comes this night to Messina\n\
|
comes this night to Messina\n\
|
||||||
MESSENGER\n\
|
MESSENGER\n\
|
||||||
|
|
@ -469,7 +470,7 @@ Good Signior Leonato, you are come to meet your\n\
|
||||||
trouble: the fashion of the world is to avoid\n\
|
trouble: the fashion of the world is to avoid\n\
|
||||||
cost, and you encounter it\n\
|
cost, and you encounter it\n\
|
||||||
LEONATO\n\
|
LEONATO\n\
|
||||||
Never came trouble to my house in the likeness";
|
Never came trouble to my house in the likeness of your grace";
|
||||||
|
|
||||||
TEST(liblog, max_payload) {
|
TEST(liblog, max_payload) {
|
||||||
pid_t pid = getpid();
|
pid_t pid = getpid();
|
||||||
|
|
@ -528,7 +529,7 @@ TEST(liblog, max_payload) {
|
||||||
|
|
||||||
EXPECT_EQ(true, matches);
|
EXPECT_EQ(true, matches);
|
||||||
|
|
||||||
EXPECT_LE(sizeof(max_payload_buf), static_cast<size_t>(max_len));
|
EXPECT_LE(SIZEOF_MAX_PAYLOAD_BUF, static_cast<size_t>(max_len));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(liblog, too_big_payload) {
|
TEST(liblog, too_big_payload) {
|
||||||
|
|
@ -1005,7 +1006,7 @@ TEST(liblog, android_errorWriteWithInfoLog__android_logger_list_read__data_too_l
|
||||||
const int TAG = 123456782;
|
const int TAG = 123456782;
|
||||||
const char SUBTAG[] = "test-subtag";
|
const char SUBTAG[] = "test-subtag";
|
||||||
const int UID = -1;
|
const int UID = -1;
|
||||||
const int DATA_LEN = sizeof(max_payload_buf);
|
const int DATA_LEN = SIZEOF_MAX_PAYLOAD_BUF;
|
||||||
struct logger_list *logger_list;
|
struct logger_list *logger_list;
|
||||||
|
|
||||||
pid_t pid = getpid();
|
pid_t pid = getpid();
|
||||||
|
|
@ -1076,8 +1077,8 @@ TEST(liblog, android_errorWriteWithInfoLog__android_logger_list_read__data_too_l
|
||||||
}
|
}
|
||||||
eventData += dataLen;
|
eventData += dataLen;
|
||||||
|
|
||||||
// 4 bytes for the tag, and 512 bytes for the log since the max_payload_buf should be
|
// 4 bytes for the tag, and 512 bytes for the log since the
|
||||||
// truncated.
|
// max_payload_buf should be truncated.
|
||||||
ASSERT_EQ(4 + 512, eventData - original);
|
ASSERT_EQ(4 + 512, eventData - original);
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
|
|
|
||||||
|
|
@ -265,7 +265,7 @@ static void show_help(const char *cmd)
|
||||||
" -v <format> Sets the log print format, where <format> is:\n"
|
" -v <format> Sets the log print format, where <format> is:\n"
|
||||||
" --format=<format>\n"
|
" --format=<format>\n"
|
||||||
" brief color epoch long monotonic printable process raw\n"
|
" brief color epoch long monotonic printable process raw\n"
|
||||||
" tag thread threadtime time usec UTC year zone\n\n"
|
" tag thread threadtime time uid usec UTC year zone\n\n"
|
||||||
" -D print dividers between each log buffer\n"
|
" -D print dividers between each log buffer\n"
|
||||||
" --dividers\n"
|
" --dividers\n"
|
||||||
" -c clear (flush) the entire log and exit\n"
|
" -c clear (flush) the entire log and exit\n"
|
||||||
|
|
|
||||||
|
|
@ -846,7 +846,7 @@ uint64_t LogBuffer::flushTo(
|
||||||
pthread_mutex_unlock(&mLogElementsLock);
|
pthread_mutex_unlock(&mLogElementsLock);
|
||||||
|
|
||||||
// range locking in LastLogTimes looks after us
|
// range locking in LastLogTimes looks after us
|
||||||
max = element->flushTo(reader, this);
|
max = element->flushTo(reader, this, privileged);
|
||||||
|
|
||||||
if (max == element->FLUSH_ERROR) {
|
if (max == element->FLUSH_ERROR) {
|
||||||
return max;
|
return max;
|
||||||
|
|
|
||||||
|
|
@ -194,21 +194,25 @@ size_t LogBufferElement::populateDroppedMessage(char *&buffer,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t LogBufferElement::flushTo(SocketClient *reader, LogBuffer *parent) {
|
uint64_t LogBufferElement::flushTo(SocketClient *reader, LogBuffer *parent,
|
||||||
struct logger_entry_v3 entry;
|
bool privileged) {
|
||||||
|
struct logger_entry_v4 entry;
|
||||||
|
|
||||||
memset(&entry, 0, sizeof(struct logger_entry_v3));
|
memset(&entry, 0, sizeof(struct logger_entry_v4));
|
||||||
|
|
||||||
entry.hdr_size = sizeof(struct logger_entry_v3);
|
entry.hdr_size = privileged ?
|
||||||
|
sizeof(struct logger_entry_v4) :
|
||||||
|
sizeof(struct logger_entry_v3);
|
||||||
entry.lid = mLogId;
|
entry.lid = mLogId;
|
||||||
entry.pid = mPid;
|
entry.pid = mPid;
|
||||||
entry.tid = mTid;
|
entry.tid = mTid;
|
||||||
|
entry.uid = mUid;
|
||||||
entry.sec = mRealTime.tv_sec;
|
entry.sec = mRealTime.tv_sec;
|
||||||
entry.nsec = mRealTime.tv_nsec;
|
entry.nsec = mRealTime.tv_nsec;
|
||||||
|
|
||||||
struct iovec iovec[2];
|
struct iovec iovec[2];
|
||||||
iovec[0].iov_base = &entry;
|
iovec[0].iov_base = &entry;
|
||||||
iovec[0].iov_len = sizeof(struct logger_entry_v3);
|
iovec[0].iov_len = entry.hdr_size;
|
||||||
|
|
||||||
char *buffer = NULL;
|
char *buffer = NULL;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ public:
|
||||||
uint32_t getTag(void) const;
|
uint32_t getTag(void) const;
|
||||||
|
|
||||||
static const uint64_t FLUSH_ERROR;
|
static const uint64_t FLUSH_ERROR;
|
||||||
uint64_t flushTo(SocketClient *writer, LogBuffer *parent);
|
uint64_t flushTo(SocketClient *writer, LogBuffer *parent, bool privileged);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue