libutil: add buffer state management to loggers

currently all loggers can always accept messages and never suggest
flushing buffers. in the future this may change, and at that point
we're already fully set up for it. local loggers should never keep
asynchronous (i.e. network-backed) buffers, disk buffers are fine.
networked loggers will require buffers and periodic flushes later.

Change-Id: Ide2114f5bc17f4a1d289c92ed4f9381a1d59dacf
This commit is contained in:
eldritch horrors
2025-10-13 11:26:49 +00:00
parent 38b75b7367
commit f29dfb3d3c
12 changed files with 279 additions and 140 deletions
+7 -2
View File
@@ -3,6 +3,7 @@
#include "lix/libexpr/eval-settings.hh"
#include "lix/libutil/logging.hh"
#include "tests/libexpr.hh"
namespace nix {
@@ -17,12 +18,16 @@ namespace nix {
return oss.str();
}
void log(Verbosity lvl, std::string_view s) override {
BufferState log(Verbosity lvl, std::string_view s) override
{
oss << s << std::endl;
return BufferState::HasSpace;
}
void logEI(const ErrorInfo & ei) override {
BufferState logEI(const ErrorInfo & ei) override
{
showErrorInfo(oss, ei, loggerSettings.showTrace.get());
return BufferState::HasSpace;
}
};