Merge "Fix print-logs" into mainline-prod

This commit is contained in:
Jeffrey Huang
2020-10-09 21:55:50 +00:00
committed by Android (Google) Code Review
4 changed files with 13 additions and 21 deletions

View File

@@ -216,10 +216,6 @@ cc_binary {
// address: true,
//},
},
debuggable: {
// Add a flag to enable stats log printing from statsd on debug builds.
cflags: ["-DVERY_VERBOSE_PRINTING"],
},
},
proto: {

View File

@@ -409,11 +409,9 @@ void StatsLogProcessor::OnLogEvent(LogEvent* event, int64_t elapsedRealtimeNs) {
onWatchdogRollbackOccurredLocked(event);
}
#ifdef VERY_VERBOSE_PRINTING
if (mPrintAllLogs) {
ALOGI("%s", event->ToString().c_str());
}
#endif
resetIfConfigTtlExpiredLocked(eventElapsedTimeNs);
// Hard-coded logic to update the isolated uid's in the uid-map.

View File

@@ -139,10 +139,8 @@ public:
int64_t getLastReportTimeNs(const ConfigKey& key);
inline void setPrintLogs(bool enabled) {
#ifdef VERY_VERBOSE_PRINTING
std::lock_guard<std::mutex> lock(mMetricsMutex);
mPrintAllLogs = enabled;
#endif
}
// Add a specific config key to the possible configs to dump ASAP.
@@ -276,9 +274,7 @@ private:
//Last time we wrote metadata to disk.
int64_t mLastMetadataWriteNs = 0;
#ifdef VERY_VERBOSE_PRINTING
bool mPrintAllLogs = false;
#endif
FRIEND_TEST(StatsLogProcessorTest, TestOutOfOrderLogs);
FRIEND_TEST(StatsLogProcessorTest, TestRateLimitByteSize);

View File

@@ -484,7 +484,8 @@ void StatsService::print_cmd_help(int out) {
dprintf(out, " Clear cached puller data.\n");
dprintf(out, "\n");
dprintf(out, "usage: adb shell cmd stats print-logs\n");
dprintf(out, " Only works on eng build\n");
dprintf(out, " Requires root privileges.\n");
dprintf(out, " Can be disabled by calling adb shell cmd stats print-logs 0\n");
}
status_t StatsService::cmd_trigger_broadcast(int out, Vector<String8>& args) {
@@ -865,18 +866,19 @@ status_t StatsService::cmd_clear_puller_cache(int out) {
}
status_t StatsService::cmd_print_logs(int out, const Vector<String8>& args) {
VLOG("StatsService::cmd_print_logs with Pid %i, Uid %i", AIBinder_getCallingPid(),
AIBinder_getCallingUid());
if (checkPermission(kPermissionDump)) {
bool enabled = true;
if (args.size() >= 2) {
enabled = atoi(args[1].c_str()) != 0;
}
mProcessor->setPrintLogs(enabled);
return NO_ERROR;
} else {
Status status = checkUid(AID_ROOT);
if (!status.isOk()) {
return PERMISSION_DENIED;
}
VLOG("StatsService::cmd_print_logs with pid %i, uid %i", AIBinder_getCallingPid(),
AIBinder_getCallingUid());
bool enabled = true;
if (args.size() >= 2) {
enabled = atoi(args[1].c_str()) != 0;
}
mProcessor->setPrintLogs(enabled);
return NO_ERROR;
}
bool StatsService::getUidFromArgs(const Vector<String8>& args, size_t uidArgIndex, int32_t& uid) {