summaryrefslogtreecommitdiffstats
path: root/logd
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2016-09-12 10:29:17 -0700
committerMark Salyzyn <salyzyn@google.com>2016-12-19 08:00:16 -0800
commit3296291cffd13af13ea9e60a8ac1138101cf8e4c (patch)
tree0726921364b561bf21935565907f67767a723b6e /logd
parent152b003bbfae22d10dd129d5f249daf957dc27c4 (diff)
downloadsystem_core-3296291cffd13af13ea9e60a8ac1138101cf8e4c.tar.gz
system_core-3296291cffd13af13ea9e60a8ac1138101cf8e4c.tar.bz2
system_core-3296291cffd13af13ea9e60a8ac1138101cf8e4c.zip
logd: add android::sizesTotal() function
Test: gTest liblog-unit-tests, logd-unit-tests and logcat-unit-tests Bug: 31456426 Change-Id: I6fb6cd589227fc43d22f9336e01f1bf7e3feb24c
Diffstat (limited to 'logd')
-rw-r--r--logd/LogStatistics.cpp5
-rw-r--r--logd/LogStatistics.h2
-rw-r--r--logd/LogUtils.h4
3 files changed, 10 insertions, 1 deletions
diff --git a/logd/LogStatistics.cpp b/logd/LogStatistics.cpp
index ddbb64fb1..6e63015ac 100644
--- a/logd/LogStatistics.cpp
+++ b/logd/LogStatistics.cpp
@@ -27,6 +27,8 @@
#include "LogStatistics.h"
+size_t LogStatistics::SizesTotal;
+
LogStatistics::LogStatistics() : enable(false) {
log_id_for_each(id) {
mSizes[id] = 0;
@@ -39,6 +41,8 @@ LogStatistics::LogStatistics() : enable(false) {
namespace android {
+size_t sizesTotal() { return LogStatistics::sizesTotal(); }
+
// caller must own and free character string
char *pidToName(pid_t pid) {
char *retval = NULL;
@@ -80,6 +84,7 @@ void LogStatistics::add(LogBufferElement *element) {
// elements, but we must recognize the manufactured dropped
// entry as not contributing to the lifetime totals.
mSizesTotal[log_id] += size;
+ SizesTotal += size;
++mElementsTotal[log_id];
}
diff --git a/logd/LogStatistics.h b/logd/LogStatistics.h
index 8bf655b01..613771c8b 100644
--- a/logd/LogStatistics.h
+++ b/logd/LogStatistics.h
@@ -472,6 +472,7 @@ class LogStatistics {
size_t mDroppedElements[LOG_ID_MAX];
size_t mSizesTotal[LOG_ID_MAX];
size_t mElementsTotal[LOG_ID_MAX];
+ static size_t SizesTotal;
bool enable;
// uid to size list
@@ -554,6 +555,7 @@ public:
}
size_t sizesTotal(log_id_t id) const { return mSizesTotal[id]; }
size_t elementsTotal(log_id_t id) const { return mElementsTotal[id]; }
+ static size_t sizesTotal() { return SizesTotal; }
std::string format(uid_t uid, pid_t pid, unsigned int logMask) const;
diff --git a/logd/LogUtils.h b/logd/LogUtils.h
index d300a2a43..70f24e4d9 100644
--- a/logd/LogUtils.h
+++ b/logd/LogUtils.h
@@ -33,7 +33,9 @@ namespace android {
char *uidToName(uid_t uid);
void prdebug(const char *fmt, ...) __printflike(1, 2);
-// Furnished in LogStatistics.cpp. Caller must own and free returned value
+// Furnished in LogStatistics.cpp.
+size_t sizesTotal();
+// Caller must own and free returned value
char *pidToName(pid_t pid);
char *tidToName(pid_t tid);