statsd: parse the new format of stats log
+ Changed how we construct LogEvent, now it's based on the context from log_msg
without making a copy of the list.
+ All stats logs now have the same event tag, the atom id is the first elem in the log.
Test: statsd_test
Change-Id: I4419380f2ee1c2b2155d427b9f2adb78883b337f
diff --git a/cmds/statsd/src/logd/LogEvent.h b/cmds/statsd/src/logd/LogEvent.h
index 2984940..7e8a96b 100644
--- a/cmds/statsd/src/logd/LogEvent.h
+++ b/cmds/statsd/src/logd/LogEvent.h
@@ -21,6 +21,7 @@
#include <android/util/ProtoOutputStream.h>
#include <log/log_event_list.h>
#include <log/log_read.h>
+#include <private/android_logger.h>
#include <utils/Errors.h>
#include <memory>
@@ -45,12 +46,9 @@
explicit LogEvent(log_msg& msg);
/**
- * Constructs a LogEvent with the specified tag and creates an android_log_event_list in write
- * mode. Obtain this list with the getter. Make sure to call init() before attempting to read
- * any of the values. This constructor is useful for unit-testing since we can't pass in an
- * android_log_event_list since there is no copy constructor or assignment operator available.
+ * Constructs a LogEvent with synthetic data for testing. Must call init() before reading.
*/
- explicit LogEvent(int tag, uint64_t timestampNs);
+ explicit LogEvent(int32_t tagId, uint64_t timestampNs);
~LogEvent();
@@ -76,6 +74,17 @@
float GetFloat(size_t key, status_t* err) const;
/**
+ * Write test data to the LogEvent. This can only be used when the LogEvent is constructed
+ * using LogEvent(tagId, timestampNs). You need to call init() before you can read from it.
+ */
+ bool write(uint32_t value);
+ bool write(int32_t value);
+ bool write(uint64_t value);
+ bool write(int64_t value);
+ bool write(const string& value);
+ bool write(float value);
+
+ /**
* Return a string representation of this event.
*/
string ToString() const;
@@ -91,13 +100,6 @@
KeyValuePair GetKeyValueProto(size_t key) const;
/**
- * A pointer to the contained log_event_list.
- *
- * @return The android_log_event_list contained within.
- */
- android_log_event_list* GetAndroidLogEventList();
-
- /**
* Used with the constructor where tag is passed in. Converts the log_event_list to read mode
* and prepares the list for reading.
*/
@@ -113,16 +115,11 @@
/**
* Parses a log_msg into a LogEvent object.
*/
- void init(const log_msg& msg);
-
- /**
- * Parses a log_msg into a LogEvent object.
- */
- void init(int64_t timestampNs, android_log_event_list* reader);
+ void init(android_log_context context);
vector<android_log_list_element> mElements;
- // Need a copy of the android_log_event_list so the strings are not cleared.
- android_log_event_list mList;
+
+ android_log_context mContext;
uint64_t mTimestampNs;