Log: carry call-site source_location through to the sink

Every log line showed LoggingAdapter.hpp as its source because make_sink
called Void::Logging::Logger::log() with a defaulted source_location captured
inside the adapter, discarding the real call site.

Capture std::source_location at each Void::Log::{info,warn,...} call via an
FmtLoc wrapper (the same trick Logger uses internally), thread it through a
4-argument Sink, and forward it from make_sink to logger.log(). Sinks now
receive the originating file/line/function.

Formatted emission is routed through a single non-overloaded Detail::emit():
forwarding a (level, module, std::string, source_location) call to the public
log() would otherwise also match the variadic log() overload, deducing
source_location as a format argument and failing in FmtLoc's consteval ctor.

Sink is now a 4-arg callable; updated the bundled tests accordingly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Opus 4.8 committed 2026-06-25 02:35:42 +03:00
1 parent e4ddb0c8c4
commit 2d3f9dc319
5 files changed
+97 -49

No files matched your search

+2 -1
View File
@@ -147,7 +147,8 @@ Void::Testing::Test filesystem_ops_emit_log_events()
int debug_count = 0;
int warning_count = 0;
Void::Log::set_sink(
[&](Void::Log::Level l, std::string_view, std::string_view) {
[&](Void::Log::Level l, std::string_view, std::string_view,
const std::source_location&) {
if (l == Void::Log::Level::Debug) {
++debug_count;
}