diff options
author | Mark Salyzyn <salyzyn@google.com> | 2015-07-23 09:22:50 -0700 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-11-01 04:29:12 -0800 |
commit | 4f8d719dc4306c1daba79a5143217f056ace2427 (patch) | |
tree | 7b94fc3d0588e71425aeaa6a67a5e213b03e3a58 /logd | |
parent | 67c96c8d5a59e071983270ddd54bad8d0d744d95 (diff) | |
download | system_core-4f8d719dc4306c1daba79a5143217f056ace2427.zip system_core-4f8d719dc4306c1daba79a5143217f056ace2427.tar.gz system_core-4f8d719dc4306c1daba79a5143217f056ace2427.tar.bz2 |
healthd: logd: add timestamp to kernel logged battery messages
Aid monotonic to realtime logging synchronization correction in
the Android ecosystem by providing a periodic notification. We
now have the following messages in the kernel logs:
- PM: suspend entry %Y-%m-%d %H:%M:%S.%09q UTC
- PM: suspend exit %Y-%m-%d %H:%M:%S.%09q UTC
- Suspended for %s.%03q seconds
- healthd: battery l=100 ... %Y-%m-%d %H:%M:%S.%09q UTC
Alter klogd to resynchronize on healthd messages as well.
NB: Time using strftime format, %q is a reference to fractional
second as introduced into log_time strptime method.
Bug: 21868540
Change-Id: I854afc0a07dff9c7f26d2b2f68990e52bf90e300
Diffstat (limited to 'logd')
-rw-r--r-- | logd/LogKlog.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/logd/LogKlog.cpp b/logd/LogKlog.cpp index eff26f5..1e6f55f 100644 --- a/logd/LogKlog.cpp +++ b/logd/LogKlog.cpp @@ -254,6 +254,7 @@ void LogKlog::sniffTime(log_time &now, const char **buf, bool reverse) { if ((cp = now.strptime(*buf, "[ %s.%q]"))) { static const char suspend[] = "PM: suspend entry "; static const char resume[] = "PM: suspend exit "; + static const char healthd[] = "healthd: battery "; static const char suspended[] = "Suspended for "; if (isspace(*cp)) { @@ -263,6 +264,15 @@ void LogKlog::sniffTime(log_time &now, const char **buf, bool reverse) { calculateCorrection(now, cp + sizeof(suspend) - 1); } else if (!strncmp(cp, resume, sizeof(resume) - 1)) { calculateCorrection(now, cp + sizeof(resume) - 1); + } else if (!strncmp(cp, healthd, sizeof(healthd) - 1)) { + // look for " 2???-??-?? ??:??:??.????????? ???" + const char *tp; + for (tp = cp + sizeof(healthd) - 1; *tp && (*tp != '\n'); ++tp) { + if ((tp[0] == ' ') && (tp[1] == '2') && (tp[5] == '-')) { + calculateCorrection(now, tp + 1); + break; + } + } } else if (!strncmp(cp, suspended, sizeof(suspended) - 1)) { log_time real; char *endp; |