Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c4dfae56 authored by Joe Onorato's avatar Joe Onorato
Browse files

Introduce a new wrapper for log_msg -- LogEvent

It stores all of the parsed fields in a single vector, and
provides accessor methods to get at fields by index with
their correct type.

Test: statsd_test
Change-Id: I4fa94e4ce52db3ac87f19b62f9c85398de6e8145
parent 9fc9edf9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ statsd_common_src := \
    src/config/ConfigManager.cpp \
    src/external/KernelWakelockPuller.cpp \
    src/external/StatsPullerManager.cpp \
    src/logd/LogEvent.cpp \
    src/logd/LogListener.cpp \
    src/logd/LogReader.cpp \
    src/matchers/CombinationLogMatchingTracker.cpp \
+3 −1
Original line number Diff line number Diff line
@@ -41,10 +41,12 @@ StatsLogProcessor::~StatsLogProcessor() {
}

// TODO: what if statsd service restarts? How do we know what logs are already processed before?
void StatsLogProcessor::OnLogEvent(const log_msg& msg) {
void StatsLogProcessor::OnLogEvent(const LogEvent& msg) {
    // TODO: Use EventMetric to filter the events we want to log.
    /* TODO: Convert this when we have the generic protobuf writing library in.
    EventMetricData eventMetricData = parse(msg);
    m_dropbox_writer.addEventMetricData(eventMetricData);
    */

    // pass the event to metrics managers.
    for (auto& pair : mMetricsManagers) {
+1 −2
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@

#include "frameworks/base/cmds/statsd/src/statsd_config.pb.h"

#include <log/logprint.h>
#include <stdio.h>
#include <unordered_map>

@@ -37,7 +36,7 @@ public:
    StatsLogProcessor(const sp<UidMap> &uidMap);
    virtual ~StatsLogProcessor();

    virtual void OnLogEvent(const log_msg& msg);
    virtual void OnLogEvent(const LogEvent& event);

    void OnConfigUpdated(const ConfigKey& key, const StatsdConfig& config);
    void OnConfigRemoved(const ConfigKey& key);
+2 −2
Original line number Diff line number Diff line
@@ -436,8 +436,8 @@ void StatsService::Startup() {
    mConfigManager->Startup();
}

void StatsService::OnLogEvent(const log_msg& msg) {
    mProcessor->OnLogEvent(msg);
void StatsService::OnLogEvent(const LogEvent& event) {
    mProcessor->OnLogEvent(event);
}

}  // namespace statsd
+1 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ public:
    /**
     * Called by LogReader when there's a log event to process.
     */
    virtual void OnLogEvent(const log_msg& msg);
    virtual void OnLogEvent(const LogEvent& event);

    // TODO: public for testing since statsd doesn't run when system starts. Change to private
    // later.
Loading