diff options
author | Mark Salyzyn <salyzyn@google.com> | 2014-02-14 16:05:05 -0800 |
---|---|---|
committer | Mark Salyzyn <salyzyn@google.com> | 2014-03-14 10:23:51 -0700 |
commit | fa3716b2501ccddc8e0cd30f6343692b8deb7639 (patch) | |
tree | cee7ad53c6d2e9d2aa972686ef7ea203c9d75c28 /liblog/log_read.c | |
parent | 6ab10a1c17d048e88f929d35293d266b6480f6d6 (diff) | |
download | system_core-fa3716b2501ccddc8e0cd30f6343692b8deb7639.tar.gz system_core-fa3716b2501ccddc8e0cd30f6343692b8deb7639.tar.bz2 system_core-fa3716b2501ccddc8e0cd30f6343692b8deb7639.zip |
logd: liblog: logcat: Arbitrary time to tail
Change-Id: I10e8d92c933e31ee11e78d2d1114261a30c4be0e
Diffstat (limited to 'liblog/log_read.c')
-rw-r--r-- | liblog/log_read.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/liblog/log_read.c b/liblog/log_read.c index e4acac2af..d96f12985 100644 --- a/liblog/log_read.c +++ b/liblog/log_read.c @@ -16,6 +16,7 @@ #include <errno.h> #include <fcntl.h> +#include <inttypes.h> #include <signal.h> #include <stddef.h> #define NOMINMAX /* for windows to suppress definition of min in stdlib.h */ @@ -234,6 +235,7 @@ struct logger_list { struct listnode node; int mode; unsigned int tail; + log_time start; pid_t pid; int sock; }; @@ -441,6 +443,8 @@ struct logger_list *android_logger_list_alloc(int mode, list_init(&logger_list->node); logger_list->mode = mode; + logger_list->start.tv_sec = 0; + logger_list->start.tv_nsec = 0; logger_list->tail = tail; logger_list->pid = pid; logger_list->sock = -1; @@ -448,6 +452,27 @@ struct logger_list *android_logger_list_alloc(int mode, return logger_list; } +struct logger_list *android_logger_list_alloc_time(int mode, + log_time start, + pid_t pid) +{ + struct logger_list *logger_list; + + logger_list = calloc(1, sizeof(*logger_list)); + if (!logger_list) { + return NULL; + } + + list_init(&logger_list->node); + logger_list->mode = mode; + logger_list->start = start; + logger_list->tail = 0; + logger_list->pid = pid; + logger_list->sock = -1; + + return logger_list; +} + /* android_logger_list_register unimplemented, no use case */ /* android_logger_list_unregister unimplemented, no use case */ @@ -564,6 +589,15 @@ int android_logger_list_read(struct logger_list *logger_list, cp += ret; } + if (logger_list->start.tv_sec || logger_list->start.tv_nsec) { + ret = snprintf(cp, remaining, " start=%" PRIu32 ".%09" PRIu32, + logger_list->start.tv_sec, + logger_list->start.tv_nsec); + ret = min(ret, remaining); + remaining -= ret; + cp += ret; + } + if (logger_list->pid) { ret = snprintf(cp, remaining, " pid=%u", logger_list->pid); ret = min(ret, remaining); |