Implemented typed, thread-specific logging system. Currently supported types are:
* Strings
* Integers
* Floats
* Timestamps
* Process IDs
Added printf-like formatted logging using mentioned types.
Test: included in this CL
Bug: 29421410
Change-Id: Ie07b78d8d39c32fcc8a122ffa9b1b7082800b990
diff --git a/include/media/nbaio/NBLog.h b/include/media/nbaio/NBLog.h
index acf2d31..ff10b8c 100644
--- a/include/media/nbaio/NBLog.h
+++ b/include/media/nbaio/NBLog.h
@@ -40,6 +40,12 @@
EVENT_RESERVED,
EVENT_STRING, // ASCII string, not NUL-terminated
EVENT_TIMESTAMP, // clock_gettime(CLOCK_MONOTONIC)
+ EVENT_INTEGER,
+ EVENT_FLOAT,
+ EVENT_PID,
+ EVENT_START_FMT, // logFormat start event: entry includes format string, following
+ // entries contain format arguments
+ EVENT_END_FMT, // end of logFormat argument list
};
// ---------------------------------------------------------------------------
@@ -73,6 +79,13 @@
// byte[2+mLength] duplicate copy of mLength to permit reverse scan
// byte[3+mLength] start of next log entry
+ static void appendInt(String8 *body, const void *data);
+ static void appendFloat(String8 *body, const void *data);
+ static void appendPID(String8 *body, const void *data);
+ static int handleFormat(const char *fmt, size_t length, const uint8_t *data,
+ String8 *timestamp, String8 *body);
+ static void appendTimestamp(String8 *body, const void *data);
+
public:
// Located in shared memory, must be POD.
@@ -133,7 +146,15 @@
virtual void logf(const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
virtual void logvf(const char *fmt, va_list ap);
virtual void logTimestamp();
- virtual void logTimestamp(const struct timespec& ts);
+ virtual void logTimestamp(const struct timespec &ts);
+ virtual void logInteger(const int x);
+ virtual void logFloat(const float x);
+ virtual void logPID();
+ virtual void logFormat(const char *fmt, ...);
+ virtual void logVFormat(const char *fmt, va_list ap);
+ virtual void logStart(const char *fmt);
+ virtual void logEnd();
+
virtual bool isEnabled() const;
@@ -170,7 +191,12 @@
virtual void logf(const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
virtual void logvf(const char *fmt, va_list ap);
virtual void logTimestamp();
- virtual void logTimestamp(const struct timespec& ts);
+ virtual void logTimestamp(const struct timespec &ts);
+ virtual void logInteger(const int x);
+ virtual void logFloat(const float x);
+ virtual void logPID();
+ virtual void logStart(const char *fmt);
+ virtual void logEnd();
virtual bool isEnabled() const;
virtual bool setEnabled(bool enabled);