Status LoggerPlugin::call(const PluginRequest& request, PluginResponse& response) { QueryLogItem item; std::vector<StatusLogLine> intermediate_logs; if (request.count("string") > 0) { auto status = Status(0, "OK"); if (request.count("category") && request.at("category") == "event") { // Optionally overload the logEvent method, but receive a duplicate. // message to log string. deserializeQueryLogItemJSON(request.at("event"), item); status = this->logEvent(item); } if (status.ok()) { return this->logString(request.at("string")); } else { return status; } } else if (request.count("snapshot") > 0) { deserializeQueryLogItemJSON(request.at("snapshot"), item); return this->logSnapshot(item); } else if (request.count("health") > 0) { deserializeQueryLogItemJSON(request.at("health"), item); return this->logHealth(item); } else if (request.count("init") > 0) { deserializeIntermediateLog(request, intermediate_logs); return this->init(request.at("init"), intermediate_logs); } else if (request.count("status") > 0) { deserializeIntermediateLog(request, intermediate_logs); return this->logStatus(intermediate_logs); } else { return Status(1, "Unsupported call to logger plugin"); } }
TEST_F(ResultsTests, test_deserialize_query_log_item_json) { auto results = getSerializedQueryLogItemJSON(); // Pull the serialized JSON back into a QueryLogItem output container. QueryLogItem output; auto s = deserializeQueryLogItemJSON(results.first, output); EXPECT_TRUE(s.ok()); // The output container should match the input query data. EXPECT_EQ(output, results.second); }