liblog: logcat: add epoch and monotonic format modifiers
- '-v epoch' prints seconds since Jan 1 1970
- '-v monotonic' print cpu seconds since start of device
- '-T sssss.mmm...' as alternate tail time format
NB: monotonic is a best estimate and may be out by a few ms
given the synchronization source clue accuracy.
Bug: 23668800
Change-Id: Ieb924b6d3817669c7e53beb9c970fb626eaad460
diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp
index ddbfb3e..cb9a85b 100644
--- a/logcat/logcat.cpp
+++ b/logcat/logcat.cpp
@@ -259,8 +259,8 @@
" -r <kbytes> Rotate log every kbytes. Requires -f\n"
" -n <count> Sets max number of rotated logs to <count>, default 4\n"
" -v <format> Sets the log print format, where <format> is:\n\n"
- " brief color long printable process raw tag thread\n"
- " threadtime time usec UTC year zone\n\n"
+ " brief color epoch long monotonic printable process raw\n"
+ " tag thread threadtime time usec UTC year zone\n\n"
" -D print dividers between each log buffer\n"
" -c clear (flush) the entire log and exit\n"
" -d dump the log and then exit (don't block)\n"
@@ -269,7 +269,7 @@
" -T <count> print only the most recent <count> lines (does not imply -d)\n"
" -T '<time>' print most recent lines since specified time (not imply -d)\n"
" count is pure numerical, time is 'MM-DD hh:mm:ss.mmm...'\n"
- " or 'YYYY-MM-DD hh:mm:ss.mmm...' format\n"
+ " 'YYYY-MM-DD hh:mm:ss.mmm...' or 'sssss.mmm...' format\n"
" -g get the size of the log's ring buffer and exit\n"
" -L dump logs from prior to last reboot\n"
" -b <buffer> Request alternate ring buffer, 'main', 'system', 'radio',\n"
@@ -384,7 +384,11 @@
if (ep) {
return ep;
}
- return t.strptime(cp, "%Y-%m-%d %H:%M:%S.%q");
+ ep = t.strptime(cp, "%Y-%m-%d %H:%M:%S.%q");
+ if (ep) {
+ return ep;
+ }
+ return t.strptime(cp, "%s.%q");
}
// Find last logged line in gestalt of all matching existing output files