Logger: route every logger to one sink; buffered lines keep their own time

Logger::RouteAll lets a program that owns its terminal send every Logger made after the call
to a single sink, at debug level, without the version line each one opened with. rugnux uses it
to write the whole log to a file and show only warnings and errors among its own step lines.

A Buffered logger now replays each line with the time it was logged at rather than the time of
the replay, so a timestamped log shows when the work happened (the P1 cross-check merge runs
beside the analyses and its lines used to carry the replay time).

HDF5DataFile's destructor reports a failed close through the logger instead of std::cerr.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SVmAWnzCmRKAXVUCdc4iNi
This commit is contained in:
2026-10-07 12:11:21 +02:00
co-authored by Claude Opus 5.5
parent 5282dd6199
commit 91bfb4ae51
3 changed files with 34 additions and 7 deletions
+3 -2
View File
@@ -18,6 +18,7 @@
#include "../include/spdlog/fmt/fmt.h"
#include "HDF5NXmx.h"
#include "../common/time_utc.h"
#include "../common/Logger.h"
HDF5DataFile::HDF5DataFile(const StartMessage &msg, uint64_t file_number, const std::string &filename) :
filename(filename),
@@ -123,9 +124,9 @@ HDF5DataFile::~HDF5DataFile() {
std::filesystem::remove(tmp_filename, ec);
}
} catch (const std::exception &e) {
std::cerr << "HDF5DataFile::~HDF5DataFile: " << e.what() << std::endl;
Logger("HDF5DataFile").Error("Closing the data file failed: {}", e.what());
} catch (...) {
std::cerr << "HDF5DataFile::~HDF5DataFile: Unknown error " << std::endl;
Logger("HDF5DataFile").Error("Closing the data file failed with an unknown error");
}
}
}