Overhaul Logging and Configuration; integrate the log facade library-wide

Void::Log facade (header-only, macro-free):
- Leveled function templates trace/debug/info/warn/error/fatal(module,
  fmt, args...) with lazy formatting - a disabled call is one relaxed
  atomic load, no allocation, no formatting.
- Global min level + per-module overrides (can raise or lower); empty
  sink/Disabled level = logging fully off; set_sink remains the splice
  point for external logging libraries.

Void::Logging::Logger - async by default, one class for both modes:
- Mode::Async (default): lock-free MPSC queue + logger-owned worker
  delivering batches via on_flush outside any lock; Immediate/Buffered
  give synchronous behavior via constructor arg or set_mode at runtime.
- Bounded queue with OverflowPolicy{Block, DropNewest, DropOldest};
  flush() (now virtual) blocks until everything submitted is delivered;
  base destructor only stops/joins the worker, never touches virtuals.
- Fixed a wakeup race: stale park token + fresh release overflowed the
  binary semaphore; wakeup is a counting semaphore (spurious wakes are
  absorbed by the worker loop).

New sinks and formatters:
- RotatingFileLogger (size-based rotation, max-files cap), NullLogger,
  CallbackLogger, MultiLogger (tee via new Logger::relay), SyslogLogger.
- Formatter interface: PatternFormatter ({time}/{level}/{scopes}/...),
  JsonLinesFormatter, LogfmtFormatter; installable on Console/File/
  Rotating sinks. Console/File sinks now default to Async.
- Logging::from_config builds the whole sink tree from Config keys;
  apply_facade_config drives facade levels.

Configuration:
- Typed get_as<T>/get_or_as<T> (numbers, bool spellings, enums by name,
  chrono durations), dotted keys, subtree(), sorted keys().
- New sources: from_env_prefix (APP_LOG__LEVEL -> log.level), from_ini
  (sections as prefixes), from_json (objects/arrays flattened),
  from_args (--key=value / --key value / --flag).
- Bind.hpp: reflection bind<T>(cfg, prefix) fills aggregates; defaults
  in the struct are the schema; nested aggregates, optional, vector.
- Watch.hpp: ConfigWatch reloads on change with per-key diff; parse
  failures keep the previous config.

System: new FileSystem::FileWatcher - debounced polling watcher (stable
mtime+size across N polls), callbacks off-thread, deletion events;
shared groundwork for plugin hot-reload.

Sweep: all internal Void::Log::log call sites migrated to the leveled
API ("Umbrella.Feature" labels); Plugin loader now logs load/reload.

918 tests green (28 new), stable across 30 consecutive runs, ASan+UBSan
clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Fable 5 committed 2026-06-13 00:11:13 +03:00
1 parent 8a6065539a
commit c74a02a5a5
43 files changed
+3889 -236

No files matched your search

+11 -1
View File
@@ -1,3 +1,4 @@
#include <Void/Log/Log.hpp>
#include <Void/Plugin/Loader.hpp>
#if defined(__unix__) || defined(__APPLE__)
@@ -95,10 +96,15 @@ PluginLoader::load(std::filesystem::path path)
PluginLoader ldr;
ldr.path_ = path;
if (auto r = ldr.load_from(path); !r)
if (auto r = ldr.load_from(path); !r) {
Void::Log::warn("Plugin", "load '{}' failed: {}", path.string(),
to_string(r.error()));
return std::unexpected{r.error()};
}
ldr.plugin_->on_load();
Void::Log::info("Plugin", "loaded '{}' ({} v{})", path.string(),
ldr.info_.name, ldr.info_.plugin_version);
return ldr;
}
@@ -148,6 +154,8 @@ std::expected<void, LoadError> PluginLoader::reload()
if (auto r = next.load_from(tmp); !r) {
std::error_code ec;
std::filesystem::remove(tmp, ec);
Void::Log::warn("Plugin", "reload '{}' failed: {}; keeping old",
path_.string(), to_string(r.error()));
return r;
}
@@ -160,6 +168,8 @@ std::expected<void, LoadError> PluginLoader::reload()
*this = std::move(next);
plugin_->on_load();
Void::Log::info("Plugin", "reloaded '{}' ({} v{})", path_.string(),
info_.name, info_.plugin_version);
std::error_code ec;
std::filesystem::remove(tmp, ec);