32 _internalLogBuffer.push_back({
"warn", std::vector<std::pair<std::string, std::string>>()});
33 _internalLogBuffer.push_back({
"error", std::vector<std::pair<std::string, std::string>>()});
34 _internalLogBuffer.push_back({
"critical", std::vector<std::pair<std::string, std::string>>()});
37 _basicInformation =
"";
38 _basicInformation += std::string(R
"("release_version":"v)") + PROJECT_FULL_REVISION + "\",";
39 _basicInformation += std::string(R
"("release_date":")") + PROJECT_BUILD_DATE + " " + PROJECT_BUILD_TIME +
"\",";
40 _basicInformation += std::string(R
"("compiler_name":")") + COMPILER_NAME + "\",";
41 _basicInformation += std::string(R
"("compiler_version":")") + COMPILER_VERSION + "\",";
42 _basicInformation += std::string(R
"("build":")") + BUILD_TYPE + "\",";
45 std::array<char, BUFSIZ> hostBuffer{};
46 gethostname(hostBuffer.data(), BUFSIZ);
50 const std::filesystem::path cpuInfoPath =
"/proc/cpuinfo";
74 if (msg.level >= spdlog::level::debug && msg.level <= spdlog::level::critical)
77 {std::to_string(msg.time.time_since_epoch().count()),
78 std::string(msg.payload.data(), msg.payload.size())});
87 std::ostringstream sStream;
89 sStream <<
"{\"streams\":[";
92 if (entry.logs.empty())
102 sStream <<
"{\"stream\":{" <<
_basicInformation + R
"("level":")" << entry.level << R"("},"values":[)";
104 bool subflag =
false;
105 for (
const auto &subentry : entry.logs)
112 sStream <<
"[\"" << subentry.first <<
"\",\"" << subentry.second <<
"\"]";
123 std::string recvData;
124 HttpStatus::Code replyCode = HttpStatus::Code::xxx_max;
125 _connHandler->sendPOSTRequest(
"/loki/api/v1/push", sStream.str(), recvData, replyCode);