Merge changes Ie7a5303e,I2b3c2ac4 am: 3a052c42be
am: 3bcb013833
Change-Id: Ia039ed201b619ef163ab781ae512d74d5e4a80c5
This commit is contained in:
commit
8295e39d4f
4 changed files with 30 additions and 11 deletions
|
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
/* struct log_time is a wire-format variant of struct timespec */
|
/* struct log_time is a wire-format variant of struct timespec */
|
||||||
#define NS_PER_SEC 1000000000ULL
|
#define NS_PER_SEC 1000000000ULL
|
||||||
|
#define US_PER_SEC 1000000ULL
|
||||||
|
#define MS_PER_SEC 1000ULL
|
||||||
|
|
||||||
#ifndef __struct_log_time_defined
|
#ifndef __struct_log_time_defined
|
||||||
#define __struct_log_time_defined
|
#define __struct_log_time_defined
|
||||||
|
|
@ -148,6 +150,14 @@ struct log_time {
|
||||||
uint64_t nsec() const {
|
uint64_t nsec() const {
|
||||||
return static_cast<uint64_t>(tv_sec) * NS_PER_SEC + tv_nsec;
|
return static_cast<uint64_t>(tv_sec) * NS_PER_SEC + tv_nsec;
|
||||||
}
|
}
|
||||||
|
uint64_t usec() const {
|
||||||
|
return static_cast<uint64_t>(tv_sec) * US_PER_SEC +
|
||||||
|
tv_nsec / (NS_PER_SEC / US_PER_SEC);
|
||||||
|
}
|
||||||
|
uint64_t msec() const {
|
||||||
|
return static_cast<uint64_t>(tv_sec) * MS_PER_SEC +
|
||||||
|
tv_nsec / (NS_PER_SEC / MS_PER_SEC);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_
|
#ifdef _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_
|
||||||
static const char default_format[];
|
static const char default_format[];
|
||||||
|
|
|
||||||
|
|
@ -208,8 +208,7 @@ int LogBuffer::log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid,
|
||||||
if (!__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE)) {
|
if (!__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE)) {
|
||||||
// Log traffic received to total
|
// Log traffic received to total
|
||||||
pthread_mutex_lock(&mLogElementsLock);
|
pthread_mutex_lock(&mLogElementsLock);
|
||||||
stats.add(elem);
|
stats.addTotal(elem);
|
||||||
stats.subtract(elem);
|
|
||||||
pthread_mutex_unlock(&mLogElementsLock);
|
pthread_mutex_unlock(&mLogElementsLock);
|
||||||
delete elem;
|
delete elem;
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
|
|
@ -320,8 +319,7 @@ int LogBuffer::log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid,
|
||||||
pthread_mutex_unlock(&mLogElementsLock);
|
pthread_mutex_unlock(&mLogElementsLock);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
stats.add(currentLast);
|
stats.addTotal(currentLast);
|
||||||
stats.subtract(currentLast);
|
|
||||||
delete currentLast;
|
delete currentLast;
|
||||||
swab = total;
|
swab = total;
|
||||||
event->payload.data = htole32(swab);
|
event->payload.data = htole32(swab);
|
||||||
|
|
@ -337,8 +335,7 @@ int LogBuffer::log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count) {
|
if (count) {
|
||||||
stats.add(currentLast);
|
stats.addTotal(currentLast);
|
||||||
stats.subtract(currentLast);
|
|
||||||
currentLast->setDropped(count);
|
currentLast->setDropped(count);
|
||||||
}
|
}
|
||||||
droppedElements[log_id] = currentLast;
|
droppedElements[log_id] = currentLast;
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
@ -70,20 +71,30 @@ char* pidToName(pid_t pid) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LogStatistics::addTotal(LogBufferElement* element) {
|
||||||
|
if (element->getDropped()) return;
|
||||||
|
|
||||||
|
log_id_t log_id = element->getLogId();
|
||||||
|
unsigned short size = element->getMsgLen();
|
||||||
|
mSizesTotal[log_id] += size;
|
||||||
|
SizesTotal += size;
|
||||||
|
++mElementsTotal[log_id];
|
||||||
|
}
|
||||||
|
|
||||||
void LogStatistics::add(LogBufferElement* element) {
|
void LogStatistics::add(LogBufferElement* element) {
|
||||||
log_id_t log_id = element->getLogId();
|
log_id_t log_id = element->getLogId();
|
||||||
unsigned short size = element->getMsgLen();
|
unsigned short size = element->getMsgLen();
|
||||||
mSizes[log_id] += size;
|
mSizes[log_id] += size;
|
||||||
++mElements[log_id];
|
++mElements[log_id];
|
||||||
|
|
||||||
|
// When caller adding a chatty entry, they will have already
|
||||||
|
// called add() and subtract() for each entry as they are
|
||||||
|
// evaluated and trimmed, thus recording size and number of
|
||||||
|
// elements, but we must recognize the manufactured dropped
|
||||||
|
// entry as not contributing to the lifetime totals.
|
||||||
if (element->getDropped()) {
|
if (element->getDropped()) {
|
||||||
++mDroppedElements[log_id];
|
++mDroppedElements[log_id];
|
||||||
} else {
|
} else {
|
||||||
// When caller adding a chatty entry, they will have already
|
|
||||||
// called add() and subtract() for each entry as they are
|
|
||||||
// evaluated and trimmed, thus recording size and number of
|
|
||||||
// elements, but we must recognize the manufactured dropped
|
|
||||||
// entry as not contributing to the lifetime totals.
|
|
||||||
mSizesTotal[log_id] += size;
|
mSizesTotal[log_id] += size;
|
||||||
SizesTotal += size;
|
SizesTotal += size;
|
||||||
++mElementsTotal[log_id];
|
++mElementsTotal[log_id];
|
||||||
|
|
|
||||||
|
|
@ -576,6 +576,7 @@ class LogStatistics {
|
||||||
enable = true;
|
enable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addTotal(LogBufferElement* entry);
|
||||||
void add(LogBufferElement* entry);
|
void add(LogBufferElement* entry);
|
||||||
void subtract(LogBufferElement* entry);
|
void subtract(LogBufferElement* entry);
|
||||||
// entry->setDropped(1) must follow this call
|
// entry->setDropped(1) must follow this call
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue