summaryrefslogtreecommitdiffstats
path: root/liblog
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2015-09-08 08:56:32 -0700
committerMark Salyzyn <salyzyn@google.com>2015-11-03 15:15:51 -0800
commitb6bee33182cedea49199eb2252b3f3b442899c6d (patch)
tree332e29183f3b901929e48ff4da8f81452abbdc40 /liblog
parentff2e26b239e931236c9acecdc2a22d540b3e0c3d (diff)
downloadcore-b6bee33182cedea49199eb2252b3f3b442899c6d.tar.gz
core-b6bee33182cedea49199eb2252b3f3b442899c6d.tar.bz2
core-b6bee33182cedea49199eb2252b3f3b442899c6d.zip
liblog: logd: support logd.timestamp = monotonic
if ro.logd.timestamp or persist.logd.timestamp are set to the value monotonic then liblog writer, liblog printing and logd all switch to recording/printing monotonic time rather than realtime. If reinit detects a change for presist.logd.timestamp, correct the older entry timestamps in place. ToDo: A corner case condition where new log entries in monotonic time occur before logd reinit detects persist.logd.timestamp, there will be a few out-of-order entries, but with accurate timestamps. This problem does not happen for ro.logd.timestamp as it is set before logd starts. NB: This offers a nano second time accuracy on all log entries that may be more suitable for merging with other system activities, such as systrace, that also use monotonic time. This feature is for debugging. Bug: 23668800 Change-Id: Iee6dab7140061b1a6627254921411f61b01aa5c2
Diffstat (limited to 'liblog')
-rw-r--r--liblog/logd_write.c6
-rw-r--r--liblog/logprint.c13
2 files changed, 13 insertions, 6 deletions
diff --git a/liblog/logd_write.c b/liblog/logd_write.c
index bdee28f50..a4310aee1 100644
--- a/liblog/logd_write.c
+++ b/liblog/logd_write.c
@@ -191,7 +191,11 @@ static int __write_to_log_daemon(log_id_t log_id, struct iovec *vec, size_t nr)
* };
*/
- clock_gettime(CLOCK_REALTIME, &ts);
+ if (android_log_timestamp() == 'm') {
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ } else {
+ clock_gettime(CLOCK_REALTIME, &ts);
+ }
pmsg_header.magic = LOGGER_MAGIC;
pmsg_header.len = sizeof(pmsg_header) + sizeof(header);
diff --git a/liblog/logprint.c b/liblog/logprint.c
index 0ea2269ea..9f12c96db 100644
--- a/liblog/logprint.c
+++ b/liblog/logprint.c
@@ -203,7 +203,7 @@ AndroidLogFormat *android_log_format_new()
p_ret->year_output = false;
p_ret->zone_output = false;
p_ret->epoch_output = false;
- p_ret->monotonic_output = false;
+ p_ret->monotonic_output = android_log_timestamp() == 'm';
return p_ret;
}
@@ -1261,10 +1261,13 @@ char *android_log_formatLogLine (
now = entry->tv_sec;
nsec = entry->tv_nsec;
if (p_format->monotonic_output) {
- struct timespec time;
- convertMonotonic(&time, entry);
- now = time.tv_sec;
- nsec = time.tv_nsec;
+ // prevent convertMonotonic from being called if logd is monotonic
+ if (android_log_timestamp() != 'm') {
+ struct timespec time;
+ convertMonotonic(&time, entry);
+ now = time.tv_sec;
+ nsec = time.tv_nsec;
+ }
}
if (now < 0) {
nsec = NS_PER_SEC - nsec;