This commit is contained in:
Aaron Po
2026-05-15 14:11:34 -04:00
parent e6a20324e4
commit c58e4c1986
7 changed files with 24 additions and 44 deletions

View File

@@ -39,14 +39,8 @@ namespace di = boost::di;
static constexpr size_t kLogMaxCount = 512;
int main(const int argc, char** argv) {
// Configure global spdlog formatting: timestamp, level, and message.
// Use Unicode box-drawing characters to frame logs for improved readability.
// The LogDispatcher includes phase and thread info inside the message.
spdlog::set_pattern(R"(┌────────────────────────────────────────────────────────
%^%l%$ | %Y-%m-%d %H:%M:%S:%e
%v
)");
spdlog::set_level(spdlog::level::debug);
spdlog::set_pattern("│ %Y-%m-%d %H:%M:%S.%e │ %^%-7l%$ │ %v");
BoundedChannel<LogEntry> log_channel(kLogMaxCount);
auto log_dispatcher = std::make_unique<LogDispatcher>(log_channel);
std::thread log_thread([&log_dispatcher] { log_dispatcher->Run(); });
@@ -61,7 +55,7 @@ int main(const int argc, char** argv) {
#endif
log_producer->Log(LogLevel::Info, PipelinePhase::Startup,
"=== Starting Biergarten Pipeline ===");
"STARTING PIPELINE");
const std::optional<ApplicationOptions> parsed_options =
ParseArguments(argc, argv, log_producer);
@@ -83,9 +77,8 @@ int main(const int argc, char** argv) {
std::unique_ptr<IPromptDirectory> prompt_directory;
if (!options.generator.use_mocked) {
try {
prompt_directory =
std::make_unique<PromptDirectory>(options.pipeline.prompt_dir,
log_producer);
prompt_directory = std::make_unique<PromptDirectory>(
options.pipeline.prompt_dir, log_producer);
} catch (const std::exception& dir_error) {
log_producer->Log(
LogLevel::Error, PipelinePhase::Startup,
@@ -107,11 +100,11 @@ int main(const int argc, char** argv) {
di::bind<IExportService>().to<SqliteExportService>(),
di::bind<IPromptFormatter>().to<Gemma4JinjaPromptFormatter>(),
di::bind<IEnrichmentService>().to(
[options, &log_producer](const auto& inj)
-> std::unique_ptr<IEnrichmentService> {
if (options.generator.use_mocked) {
return std::make_unique<MockEnrichmentService>();
}
[options, &log_producer](
const auto& inj) -> std::unique_ptr<IEnrichmentService> {
// if (options.generator.use_mocked) {
// return std::make_unique<MockEnrichmentService>();
// }
return std::make_unique<WikipediaEnrichmentService>(
inj.template create<std::unique_ptr<WebClient>>(),
log_producer);
@@ -165,9 +158,9 @@ int main(const int argc, char** argv) {
// Attempt to use the logging infrastructure; if channel/dispatcher are
// compromised this is a best-effort fallback.
if (log_producer) {
log_producer->Log(LogLevel::Error, PipelinePhase::Teardown,
std::string("Unhandled fatal error in main: ") +
exception.what());
log_producer->Log(
LogLevel::Error, PipelinePhase::Teardown,
std::string("Unhandled fatal error in main: ") + exception.what());
}
log_channel.Close();
log_thread.join();