Merge "logd: add android::sizesTotal() function"

This commit is contained in:
Treehugger Robot 2016-12-19 23:19:11 +00:00 committed by Gerrit Code Review
commit d04fa942e5
3 changed files with 10 additions and 1 deletions

View file

@ -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];
}

View file

@ -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;

View file

@ -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);