summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2014-02-14 16:05:05 -0800
committerMark Salyzyn <salyzyn@google.com>2014-03-14 10:23:51 -0700
commitfa3716b2501ccddc8e0cd30f6343692b8deb7639 (patch)
treecee7ad53c6d2e9d2aa972686ef7ea203c9d75c28 /include
parent6ab10a1c17d048e88f929d35293d266b6480f6d6 (diff)
downloadsystem_core-fa3716b2501ccddc8e0cd30f6343692b8deb7639.zip
system_core-fa3716b2501ccddc8e0cd30f6343692b8deb7639.tar.gz
system_core-fa3716b2501ccddc8e0cd30f6343692b8deb7639.tar.bz2
logd: liblog: logcat: Arbitrary time to tail
Change-Id: I10e8d92c933e31ee11e78d2d1114261a30c4be0e
Diffstat (limited to 'include')
-rw-r--r--include/log/log_read.h32
-rw-r--r--include/log/logger.h4
2 files changed, 31 insertions, 5 deletions
diff --git a/include/log/log_read.h b/include/log/log_read.h
index 7edfe3c..bd9de12 100644
--- a/include/log/log_read.h
+++ b/include/log/log_read.h
@@ -17,11 +17,17 @@
#ifndef _LIBS_LOG_LOG_READ_H
#define _LIBS_LOG_LOG_READ_H
+#include <stdint.h>
#include <time.h>
/* struct log_time is a wire-format variant of struct timespec */
#define NS_PER_SEC 1000000000ULL
+
#ifdef __cplusplus
+
+// NB: do NOT define a copy constructor. This will result in structure
+// no longer being compatible with pass-by-value which is desired
+// efficient behavior. Also, pass-by-reference breaks C/C++ ABI.
struct log_time {
public:
uint32_t tv_sec; // good to Feb 5 2106
@@ -32,16 +38,12 @@ public:
tv_sec = T.tv_sec;
tv_nsec = T.tv_nsec;
}
- log_time(const log_time &T)
- {
- tv_sec = T.tv_sec;
- tv_nsec = T.tv_nsec;
- }
log_time(uint32_t sec, uint32_t nsec)
{
tv_sec = sec;
tv_nsec = nsec;
}
+ static const timespec EPOCH;
log_time()
{
}
@@ -86,6 +88,12 @@ public:
{
return !(*this > T);
}
+ log_time operator-= (const timespec &T);
+ log_time operator- (const timespec &T) const
+ {
+ log_time local(*this);
+ return local -= T;
+ }
// log_time
bool operator== (const log_time &T) const
@@ -114,17 +122,31 @@ public:
{
return !(*this > T);
}
+ log_time operator-= (const log_time &T);
+ log_time operator- (const log_time &T) const
+ {
+ log_time local(*this);
+ return local -= T;
+ }
uint64_t nsec() const
{
return static_cast<uint64_t>(tv_sec) * NS_PER_SEC + tv_nsec;
}
+
+ static const char default_format[];
+
+ // Add %#q for the fraction of a second to the standard library functions
+ char *strptime(const char *s, const char *format = default_format);
} __attribute__((__packed__));
+
#else
+
typedef struct log_time {
uint32_t tv_sec;
uint32_t tv_nsec;
} __attribute__((__packed__)) log_time;
+
#endif
#endif /* define _LIBS_LOG_LOG_READ_H */
diff --git a/include/log/logger.h b/include/log/logger.h
index 8dab234..3c6ea30 100644
--- a/include/log/logger.h
+++ b/include/log/logger.h
@@ -12,6 +12,7 @@
#include <stdint.h>
#include <log/log.h>
+#include <log/log_read.h>
#ifdef __cplusplus
extern "C" {
@@ -161,6 +162,9 @@ int android_logger_set_prune_list(struct logger_list *logger_list,
struct logger_list *android_logger_list_alloc(int mode,
unsigned int tail,
pid_t pid);
+struct logger_list *android_logger_list_alloc_time(int mode,
+ log_time start,
+ pid_t pid);
void android_logger_list_free(struct logger_list *logger_list);
/* In the purest sense, the following two are orthogonal interfaces */
int android_logger_list_read(struct logger_list *logger_list,