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/main.cpp b/logd/main.cpp
index 23bbf86..8713147 100644
--- a/logd/main.cpp
+++ b/logd/main.cpp
@@ -52,6 +52,7 @@
#include "LogBuffer.h"
#include "LogKlog.h"
#include "LogListener.h"
+#include "LogTags.h"
#include "LogUtils.h"
#define KMSG_PRIORITY(PRI) \
@@ -355,6 +356,9 @@
pthread_attr_destroy(&attr);
}
+ // A cache of event log tags
+ LogTags log_tags;
+
// Serves the purpose of managing the last logs times read on a
// socket connection, and as a reader lock on a range of log
// entries.
@@ -364,7 +368,7 @@
// LogBuffer is the object which is responsible for holding all
// log entries.
- logBuf = new LogBuffer(times);
+ logBuf = new LogBuffer(times, &log_tags);
signal(SIGHUP, reinit_signal_handler);
@@ -396,7 +400,7 @@
// Command listener listens on /dev/socket/logd for incoming logd
// administrative commands.
- CommandListener* cl = new CommandListener(logBuf, reader, swl);
+ CommandListener* cl = new CommandListener(logBuf, &log_tags);
if (cl->startListener()) {
return EXIT_FAILURE;
}