logd: decouple LogTags from LogBuffer
LogBuffer needs a pointer to LogTags, but it should not own the
instance. It should not provide accessors into LogTags either.
Also, clean up CommandListener a bit.
Test: logging unit tests
Change-Id: Ic0c86a2bac0c4dd80262278588b9fdc2326dbe5b
diff --git a/logd/LogBuffer.h b/logd/LogBuffer.h
index 458fbbb..b8e64d0 100644
--- a/logd/LogBuffer.h
+++ b/logd/LogBuffer.h
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-#ifndef _LOGD_LOG_BUFFER_H__
-#define _LOGD_LOG_BUFFER_H__
+#pragma once
#include <sys/types.h>
@@ -98,8 +97,6 @@
bool monotonic;
- LogTags tags;
-
LogBufferElement* lastLoggedElements[LOG_ID_MAX];
LogBufferElement* droppedElements[LOG_ID_MAX];
void log(LogBufferElement* elem);
@@ -107,7 +104,7 @@
public:
LastLogTimes& mTimes;
- explicit LogBuffer(LastLogTimes* times);
+ LogBuffer(LastLogTimes* times, LogTags* tags);
~LogBuffer();
void init();
bool isMonotonic() {
@@ -143,17 +140,6 @@
return mPrune.format();
}
- std::string formatGetEventTag(uid_t uid, const char* name,
- const char* format) {
- return tags.formatGetEventTag(uid, name, format);
- }
- std::string formatEntry(uint32_t tag, uid_t uid) {
- return tags.formatEntry(tag, uid);
- }
- const char* tagToName(uint32_t tag) {
- return tags.tagToName(tag);
- }
-
// helper must be protected directly or implicitly by wrlock()/unlock()
const char* pidToName(pid_t pid) {
return stats.pidToName(pid);
@@ -186,6 +172,6 @@
// Returns an iterator to the oldest element for a given log type, or mLogElements.end() if
// there are no logs for the given log type. Requires mLogElementsLock to be held.
LogBufferElementCollection::iterator GetOldest(log_id_t log_id);
-};
-#endif // _LOGD_LOG_BUFFER_H__
+ LogTags* tags_;
+};