Add multithreaded logging infrastructure for preparation for future designs (#225)

* Update class diagrams

* Implement BoundedChannel and multithreaded logging infra

* Integrate logging channel system

* Update string concatenations to use std::format

* Add pretty print log
This commit is contained in:
2026-05-22 22:00:38 -04:00
committed by GitHub
parent 2ee7b3d2a2
commit 6a66619c70
44 changed files with 1445 additions and 439 deletions

View File

@@ -6,7 +6,9 @@
#include "json_handling/json_loader.h"
#include <spdlog/spdlog.h>
#include <format>
#include "services/logging/logger.h"
#include <iostream>
#include <boost/json.hpp>
#include <fstream>
@@ -19,8 +21,8 @@ static std::string ReadRequiredString(const boost::json::object& object,
const char* key) {
const boost::json::value* value = object.if_contains(key);
if (value == nullptr || !value->is_string()) {
throw std::runtime_error(std::string("Missing or invalid string field: ") +
key);
throw std::runtime_error(
std::format("Missing or invalid string field: {}", key));
}
const std::string_view text = value->as_string();
return std::string(text);
@@ -30,8 +32,8 @@ static double ReadRequiredNumber(const boost::json::object& object,
const char* key) {
const boost::json::value* value = object.if_contains(key);
if (value == nullptr || !value->is_number()) {
throw std::runtime_error(std::string("Missing or invalid numeric field: ") +
key);
throw std::runtime_error(
std::format("Missing or invalid numeric field: {}", key));
}
return value->to_number<double>();
}
@@ -41,7 +43,7 @@ static std::vector<std::string> ReadRequiredStringArray(
const boost::json::value* value = object.if_contains(key);
if (value == nullptr || !value->is_array()) {
throw std::runtime_error(
std::string("Missing or invalid string array field: ") + key);
std::format("Missing or invalid string array field: {}", key));
}
const auto& array = value->as_array();
@@ -50,7 +52,7 @@ static std::vector<std::string> ReadRequiredStringArray(
for (const auto& item : array) {
if (!item.is_string()) {
throw std::runtime_error(
std::string("Missing or invalid string array field: ") + key);
std::format("Missing or invalid string array field: {}", key));
}
items.emplace_back(item.as_string());
}
@@ -58,7 +60,7 @@ static std::vector<std::string> ReadRequiredStringArray(
}
std::vector<Location> JsonLoader::LoadLocations(
const std::filesystem::path& filepath) {
const std::filesystem::path& filepath, std::shared_ptr<ILogger> logger) {
std::ifstream input(filepath);
if (!input.is_open()) {
throw std::runtime_error("Failed to open locations file: " +
@@ -104,7 +106,5 @@ std::vector<Location> JsonLoader::LoadLocations(
});
}
spdlog::info("[JsonLoader] Loaded {} locations from {}", locations.size(),
filepath.string());
return locations;
}