From 9079f7c283ae93fd0dd244bfad093ae5312a6c5b Mon Sep 17 00:00:00 2001 From: Mathew Inwood Date: Tue, 1 May 2018 10:42:24 +0100 Subject: [PATCH] Add support for logging package name. The functionality already exists in Java, add it to the C++ class too. Bug: 77517571 Test: m Test: Exercised by ag/3984344 in art Change-Id: Id27a6c506783a02e4334498dadf55167efab097f --- libmetricslogger/include/metricslogger/metrics_logger.h | 3 +++ libmetricslogger/metrics_logger.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/libmetricslogger/include/metricslogger/metrics_logger.h b/libmetricslogger/include/metricslogger/metrics_logger.h index 2c768695d..860d71d39 100644 --- a/libmetricslogger/include/metricslogger/metrics_logger.h +++ b/libmetricslogger/include/metricslogger/metrics_logger.h @@ -47,6 +47,8 @@ class ComplexEventLogger { public: // Create a complex event with category|category|. explicit ComplexEventLogger(int category); + // Set the package name that this event originates from. + void SetPackageName(const std::string& package_name); // Add tagged data to the event, with the given tag and integer value. void AddTaggedData(int tag, int32_t value); // Add tagged data to the event, with the given tag and string value. @@ -70,6 +72,7 @@ enum { LOGBUILDER_VALUE = 802, LOGBUILDER_COUNTER = 803, LOGBUILDER_HISTOGRAM = 804, + LOGBUILDER_PACKAGENAME = 806, ACTION_BOOT = 1098, FIELD_PLATFORM_REASON = 1099, diff --git a/libmetricslogger/metrics_logger.cpp b/libmetricslogger/metrics_logger.cpp index 912fa1281..6a32153c6 100644 --- a/libmetricslogger/metrics_logger.cpp +++ b/libmetricslogger/metrics_logger.cpp @@ -62,6 +62,10 @@ ComplexEventLogger::ComplexEventLogger(int category) : logger(kSysuiMultiActionT logger << LOGBUILDER_CATEGORY << category; } +void ComplexEventLogger::SetPackageName(const std::string& package_name) { + logger << LOGBUILDER_PACKAGENAME << package_name; +} + void ComplexEventLogger::AddTaggedData(int tag, int32_t value) { logger << tag << value; }